From 9dc798bc534559276a203c7b703387277863e14c Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Wed, 1 Mar 2023 14:54:22 +0800 Subject: [PATCH] ws recycle conn bug fix --- internal/msg_gateway/gate/ws_server.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/msg_gateway/gate/ws_server.go b/internal/msg_gateway/gate/ws_server.go index 81ce37d76..9025b287b 100644 --- a/internal/msg_gateway/gate/ws_server.go +++ b/internal/msg_gateway/gate/ws_server.go @@ -377,8 +377,12 @@ func (ws *WServer) delUserConn(conn *UserConn) { platform = k uid = v } - if oldConnMap, ok := ws.wsUserToConn[uid]; ok { - delete(oldConnMap, platform) + if oldConnMap, ok := ws.wsUserToConn[uid]; ok { // only recycle self conn + if oldconn, okMap := oldConnMap[platform]; okMap { + if oldconn == conn { + delete(oldConnMap, platform) + } + } ws.wsUserToConn[uid] = oldConnMap if len(oldConnMap) == 0 { delete(ws.wsUserToConn, uid)