From 998975e413c58b2605a82852514241e1b73f4e99 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 7 Sep 2023 16:03:56 +0800 Subject: [PATCH] fix --- server/websocket/internal/logic/datatransferlogic.go | 4 +--- server/websocket/internal/logic/ws_user_connect_pool.go | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 6f68bb4b..a01a9970 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -200,9 +200,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo *auth.Use //保存连接 mapConnPool.Store(uniqueId, ws) //非白板用户,需要为这个用户建立map索引便于通过用户查询 - if userInfo.IsUser() || userInfo.IsGuest() { - createUserConnPoolElement(userInfo.UserId, userInfo.GuestId, uniqueId) - } + createUserConnPoolElement(userInfo.UserId, userInfo.GuestId, uniqueId) if isFirefoxBrowser { time.Sleep(time.Second * 1) //兼容下火狐(直接发回去收不到第一条消息:有待研究) } diff --git a/server/websocket/internal/logic/ws_user_connect_pool.go b/server/websocket/internal/logic/ws_user_connect_pool.go index 51a02031..265e6490 100644 --- a/server/websocket/internal/logic/ws_user_connect_pool.go +++ b/server/websocket/internal/logic/ws_user_connect_pool.go @@ -16,6 +16,9 @@ var ( // 添加用户索引池ws连接 func createUserConnPoolElement(userId, guestId int64, uniqueId string) { + if userId == 0 && guestId == 0 { + return + } data := userConnPoolCtlChanItem{ userId: userId, guestId: guestId, @@ -34,6 +37,9 @@ func createUserConnPoolElement(userId, guestId int64, uniqueId string) { // 从用户索引池删除ws连接 func deleteUserConnPoolElement(userId, guestId int64, uniqueId string) { + if userId == 0 && guestId == 0 { + return + } data := userConnPoolCtlChanItem{ userId: userId, guestId: guestId,