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,