fusenapi/server/websocket/internal/logic/ws_resume_last_connect.go

28 lines
796 B
Go
Raw Normal View History

2023-08-11 02:49:29 +00:00
package logic
import "fusenapi/constants"
// 刷新重连请求恢复上次连接的标识
func (w *wsConnectItem) resumeLateConnect(data []byte) {
clientId := string(data)
//id长度不对
if len(clientId) != 50 {
rsp := w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "request id is invalid")
w.sendToOutChan(rsp)
return
}
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
}
//重新绑定
w.uniqueId = clientId
2023-08-15 06:04:44 +00:00
rsp := w.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, clientId)
2023-08-11 02:49:29 +00:00
w.sendToOutChan(rsp)
return
}