diff --git a/server/websocket/internal/logic/ws_reuse_last_connect.go b/server/websocket/internal/logic/ws_reuse_last_connect.go index ea8c75f1..8d591a98 100644 --- a/server/websocket/internal/logic/ws_reuse_last_connect.go +++ b/server/websocket/internal/logic/ws_reuse_last_connect.go @@ -36,10 +36,23 @@ func (w *wsConnectItem) reuseLastConnect(data []byte) { publicMutex.Lock() defer publicMutex.Unlock() //存在是不能给他申请重新绑定 - if _, ok := mapConnPool.Load(clientId); ok { - rsp := w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "id has bound by other connect ") - w.sendToOutChan(rsp) - return + if v, ok := mapConnPool.Load(clientId); ok { + obj, ok := v.(wsConnectItem) + if !ok { + logx.Error("连接断言失败") + } + //是当前自己占用 + if obj.uniqueId == w.uniqueId { + //重新绑定 + w.uniqueId = clientId + rsp := w.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, clientId) + w.sendToOutChan(rsp) + return + } else { + rsp := w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "id has bound by other connect ") + w.sendToOutChan(rsp) + return + } } //重新绑定 w.uniqueId = clientId