完善登录流程的错误处理

This commit is contained in:
flswld
2023-02-11 21:08:44 +08:00
parent 4380aea9aa
commit b5b5cf59a5
17 changed files with 253 additions and 144 deletions
+8
View File
@@ -4,6 +4,7 @@ import (
"time"
"hk4e/common/mq"
"hk4e/gate/kcp"
"hk4e/gs/model"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
@@ -87,6 +88,13 @@ func (g *GameManager) ClientTimeNotify(userId uint32, clientTime uint32) {
}
logger.Debug("client time notify, uid: %v, time: %v", userId, clientTime)
player.ClientTime = clientTime
now := time.Now().Unix()
// 客户端与服务器时间相差太过严重
if now-int64(player.ClientTime) > 60 || int64(player.ClientTime)-now > 60 {
g.KickPlayer(player.PlayerID, kcp.EnetServerKick)
logger.Error("abs of client time and server time above 60, uid: %v", userId)
}
player.LastKeepaliveTime = uint32(now)
}
func (g *GameManager) ServerAnnounceNotify(announceId uint32, announceMsg string) {