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 rsp := w.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, clientId) w.sendToOutChan(rsp) return }