fix
This commit is contained in:
parent
25bf157977
commit
a8457b7dad
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user