From a2ecd518aa3c246f145c441975711e004b2e9051 Mon Sep 17 00:00:00 2001 From: liuxiaobo <1224730913@qq.com> Date: Mon, 2 Jun 2025 15:31:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9websocket=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/client/server/login.go | 1 + server/client/server/service.go | 2 +- server/gate/server/processor.go | 2 +- 工作.txt | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/server/client/server/login.go b/server/client/server/login.go index a7fc46a..139b4ca 100644 --- a/server/client/server/login.go +++ b/server/client/server/login.go @@ -24,5 +24,6 @@ func (s *ClientService) onLogin(cMsg *pb.ClientMsg, msg *pb.S2CUserLogin) { } _ = cMsg s.userId = msg.UserId + s.client.SetUid(msg.UserId) log.DebugF("user:%v id:%v login success", s.username, msg.UserId) } diff --git a/server/client/server/service.go b/server/client/server/service.go index a1ec7cd..eb8c979 100644 --- a/server/client/server/service.go +++ b/server/client/server/service.go @@ -61,7 +61,7 @@ func newClientService(serviceId int) *ClientService { func (s *ClientService) loopLoginHour() { s.login() - time.AfterFunc(time.Hour, s.loopLoginHour) + time.AfterFunc(5*time.Minute, s.loopLoginHour) } func (s *ClientService) OnInit() { diff --git a/server/gate/server/processor.go b/server/gate/server/processor.go index 2da73d1..7136d57 100644 --- a/server/gate/server/processor.go +++ b/server/gate/server/processor.go @@ -47,5 +47,5 @@ func (s *GateService) onUserLogout(iMsg *ipb.InternalMsg, conn ws.IConn, msg *pb } s.SendClientMsg(conn, iMsg.ServiceName, int32(pb.MsgId_S2CUserLogoutId), msg) // 登出的清理工作由WsOnDisconnect实现 - conn.NotifyClose() + conn.Close() } diff --git a/工作.txt b/工作.txt index 106f526..797c63e 100644 --- a/工作.txt +++ b/工作.txt @@ -1,6 +1,6 @@ 1.测试gate - 1.1 每10分钟新起1000个连接,发送登陆,然后关闭。检查是否有内存及协程泄漏。 - 1.2 启动1000个链接,每小时固定发送登陆消息,一天后查看连接是否还在。检查心跳机制。 + 1.1 每10分钟新起1000个连接,发送登陆,然后关闭。检查是否有内存及协程泄漏。(有泄漏) + 1.2 启动1000个链接,每小时固定发送登陆消息,一天后查看连接是否还在。检查心跳机制。(已修复) 2.编写db服 2.1 login服向db服请求数据及向log db服写入日志。测试rpc机制。