From 1fb13fa5dece7577f0224807049d9657071e5f86 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Wed, 14 Jun 2023 15:07:53 +0800 Subject: [PATCH] refactor: ws add --- internal/msggateway/n_ws_server.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/msggateway/n_ws_server.go b/internal/msggateway/n_ws_server.go index 32b2a7283..b2adafc00 100644 --- a/internal/msggateway/n_ws_server.go +++ b/internal/msggateway/n_ws_server.go @@ -142,9 +142,9 @@ func (ws *WsServer) registerClient(client *Client) { clientOK bool oldClients []*Client ) - ws.clients.Set(client.UserID, client) oldClients, userOK, clientOK = ws.clients.Get(client.UserID, client.PlatformID) if !userOK { + ws.clients.Set(client.UserID, client) log.ZDebug(client.ctx, "user not exist", "userID", client.UserID, "platformID", client.PlatformID) atomic.AddInt64(&ws.onlineUserNum, 1) atomic.AddInt64(&ws.onlineUserConnNum, 1) @@ -157,10 +157,14 @@ func (ws *WsServer) registerClient(client *Client) { } ws.kickHandlerChan <- i log.ZDebug(client.ctx, "user exist", "userID", client.UserID, "platformID", client.PlatformID) - if clientOK { //已经有同平台的连接存在 + if clientOK { + ws.clients.Set(client.UserID, client) + //已经有同平台的连接存在 log.ZInfo(client.ctx, "repeat login", "userID", client.UserID, "platformID", client.PlatformID, "old remote addr", getRemoteAdders(oldClients)) atomic.AddInt64(&ws.onlineUserConnNum, 1) } else { + ws.clients.Set(client.UserID, client) + atomic.AddInt64(&ws.onlineUserConnNum, 1) } }