账号多终端登录提示
This commit is contained in:
parent
e6bcad1090
commit
2d46852079
@ -23,7 +23,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
RDS_SESSION = "online"
|
RDS_SESSION = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
//ERR
|
//ERR
|
||||||
|
@ -70,13 +70,18 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
|
|||||||
go this.module.ModuleTask.InitTaskAll(user.Uid)
|
go this.module.ModuleTask.InitTaskAll(user.Uid)
|
||||||
isNewUser = true
|
isNewUser = true
|
||||||
} else {
|
} else {
|
||||||
|
// 玩家是否已在线
|
||||||
if cu := this.module.modelSession.getUserSession(user.Uid); cu != nil {
|
if cu := this.module.modelSession.getUserSession(user.Uid); cu != nil {
|
||||||
if cu.SessionId != "" {
|
if cu.SessionId != "" {
|
||||||
code = pb.ErrorCode_UserLogined
|
// 通知先登录的玩家并解绑
|
||||||
return
|
this.module.SendMsgToUser(string(this.module.GetType()), "othertermlogin", &pb.UserOtherTermLoginPush{Uid: cu.Uid}, cu.Uid)
|
||||||
|
if isession, ok := this.module.ModuleBase.GetUserSession(cu.Uid); ok {
|
||||||
|
if err := isession.UnBind(); err != nil {
|
||||||
|
this.module.Errorf("解绑失败 uid:%v sessionId:%v err:%v", cu.Uid, cu.SessionId, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//bind user
|
//bind user
|
||||||
@ -88,7 +93,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
|
|||||||
}
|
}
|
||||||
|
|
||||||
//缓存user session
|
//缓存user session
|
||||||
err = this.module.modelSession.setUserSession(user.Uid, session)
|
err = this.module.modelSession.addUserSession(user.Uid, session)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.module.Errorf("set user session err:%v", err)
|
this.module.Errorf("set user session err:%v", err)
|
||||||
code = pb.ErrorCode_UserSessionNobeing
|
code = pb.ErrorCode_UserSessionNobeing
|
||||||
|
@ -44,7 +44,7 @@ func (this *ModelSession) getUserSession(uid string) (user *pb.CacheUser) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//设置用户session
|
//设置用户session
|
||||||
func (this *ModelSession) setUserSession(uid string, session comm.IUserSession) (err error) {
|
func (this *ModelSession) addUserSession(uid string, session comm.IUserSession) (err error) {
|
||||||
if err = this.AddList(comm.RDS_SESSION, uid, map[string]interface{}{
|
if err = this.AddList(comm.RDS_SESSION, uid, map[string]interface{}{
|
||||||
"uid": uid,
|
"uid": uid,
|
||||||
"sessionId": session.GetSessionId(),
|
"sessionId": session.GetSessionId(),
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user