feat(login): 优化登录逻辑增加在线状态检查 - 在踢人操作前先检查用户是否在线,避免对不在线用户执行踢人操作 - 调整设置用户在线状态的位置,确保只有在成功获取用户信息后才设置在线状态 - 修复了可能对已离线用户执行踢人操作的问题 ```
This commit is contained in:
@@ -30,13 +30,17 @@ func (h Controller) Login(data *user.MAIN_LOGIN_IN, c gnet.Conn) (result *user.L
|
||||
defer c.Close()
|
||||
return
|
||||
}
|
||||
error := Maincontroller.RPCClient.Kick(data.Head.UserID) //通知其他服务器踢人
|
||||
if error != nil {
|
||||
cool.Logger.Error(context.Background(), "踢人失败", err)
|
||||
_, erre := share.ShareManager.GetUserOnline(data.Head.UserID)
|
||||
if erre == nil {
|
||||
error := Maincontroller.RPCClient.Kick(data.Head.UserID) //通知其他服务器踢人
|
||||
if error != nil {
|
||||
cool.Logger.Error(context.Background(), "踢人失败", err)
|
||||
|
||||
defer c.Close()
|
||||
return
|
||||
defer c.Close()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
currentPlayer := player.GetPlayer(c, data.Head.UserID)
|
||||
|
||||
if currentPlayer == nil {
|
||||
@@ -49,11 +53,12 @@ func (h Controller) Login(data *user.MAIN_LOGIN_IN, c gnet.Conn) (result *user.L
|
||||
currentPlayer.Service = service.NewUserService(data.Head.UserID)
|
||||
|
||||
currentPlayer.Info = currentPlayer.Service.Info.SetLogin()
|
||||
share.ShareManager.SetUserOnline(data.Head.UserID, h.UID) //设置用户登录服务器
|
||||
if currentPlayer.Info == nil {
|
||||
defer c.Close()
|
||||
return
|
||||
}
|
||||
share.ShareManager.SetUserOnline(data.Head.UserID, h.UID) //设置用户登录服务器
|
||||
|
||||
currentPlayer.Info.UserID = data.Head.UserID
|
||||
currentPlayer.Logintime = uint32(time.Now().Unix()) //保存时间戳
|
||||
|
||||
|
||||
Reference in New Issue
Block a user