From a8457b7dadd90c6ab45c14da444180fa230c0df8 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 23 Aug 2023 16:13:14 +0800 Subject: [PATCH] fix --- server/websocket/internal/logic/datatransferlogic.go | 3 ++- server/websocket/internal/logic/ws_reuse_last_connect.go | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 1fee63bf..21ee7614 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -3,6 +3,7 @@ package logic //websocket连接 import ( "bytes" + "encoding/hex" "encoding/json" "fusenapi/constants" "fusenapi/server/websocket/internal/websocket_data" @@ -159,7 +160,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User // 获取唯一id func (l *DataTransferLogic) getUniqueId(userInfo auth.UserInfo) string { //后面拼接上用户id - uniqueId := uuid.New().String() + getUserJoinPart(userInfo.UserId, userInfo.GuestId) + uniqueId := hex.EncodeToString([]byte(uuid.New().String())) + getUserJoinPart(userInfo.UserId, userInfo.GuestId) if _, ok := mapConnPool.Load(uniqueId); ok { uniqueId = l.getUniqueId(userInfo) } diff --git a/server/websocket/internal/logic/ws_reuse_last_connect.go b/server/websocket/internal/logic/ws_reuse_last_connect.go index 5ed56d6e..dcf1b352 100644 --- a/server/websocket/internal/logic/ws_reuse_last_connect.go +++ b/server/websocket/internal/logic/ws_reuse_last_connect.go @@ -18,8 +18,8 @@ func (w *wsConnectItem) reuseLastConnect(data []byte) { return } lenClientId := len(clientId) - //id长度不对 - if lenClientId > 100 { + //id长度太长 + if lenClientId > 500 { w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "length of client id is to long")) return } @@ -65,5 +65,5 @@ func (w *wsConnectItem) reuseLastConnect(data []byte) { // 获取用户拼接部分(复用标识用到) func getUserJoinPart(userId, guestId int64) string { - return fmt.Sprintf("_%d_%d", userId, guestId) + return fmt.Sprintf("i%di%d", userId, guestId) }