From 2678cd9685e51d29f3bfd5eb4dee1d8042092693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <1@72wo.cn> Date: Sun, 26 Oct 2025 15:12:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(session):=20=E8=B0=83=E6=95=B4=E4=BC=9A?= =?UTF-8?q?=E8=AF=9D=E4=BF=9D=E5=AD=98=E6=97=B6=E9=95=BF=E4=B8=BA1?= =?UTF-8?q?=E5=B0=8F=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将会话保存时长从24小时调整为1小时,以提高会话安全性。 feat(socket): 添加强制踢出功能 在QuitSelf方法中增加强制踢出参数,当参数不为0时强制踢出所有玩家。 --- common/data/share/user.go | 2 +- common/socket/kick.go | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/common/data/share/user.go b/common/data/share/user.go index 8d1ba74b..fc92d40f 100644 --- a/common/data/share/user.go +++ b/common/data/share/user.go @@ -46,7 +46,7 @@ func (m *sessionManager) GetSession(sessionID string) (uint32, error) { // SaveSession 保存会话信息 func (m *sessionManager) SaveSession(sessionID string, userID uint32) error { - return m.sessionStore.Set(gctx.New(), sessionID, userID, time.Hour*24) + return m.sessionStore.Set(gctx.New(), sessionID, userID, time.Hour*1) } // DeleteSession 删除会话 diff --git a/common/socket/kick.go b/common/socket/kick.go index b3160dc9..c013f70c 100644 --- a/common/socket/kick.go +++ b/common/socket/kick.go @@ -12,15 +12,19 @@ func (h *Server) KickPerson(a int) error { return player.KickPlayer(uint32(a)) } + +// 参数不为0是强制踢出 func (h *Server) QuitSelf(a int) error { //TODO 这里待退出 fmt.Println("检测到退出请求") h.quit = true + if a != 0 { + player.Mainplayer.Range(func(key uint32, value *player.Player) bool { + value.Kick() + return true + }) + } - player.Mainplayer.Range(func(key uint32, value *player.Player) bool { - value.Kick() - return true - }) return nil }