This commit is contained in:
laodaming 2023-08-18 16:23:04 +08:00
parent 2d498a06a0
commit 1309473d7b

View File

@ -99,7 +99,7 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request)
)
isAuth, userInfo = l.checkAuth(r)
if !isAuth {
time.Sleep(time.Second * 1) //兼容下火狐
time.Sleep(time.Second * 1) //兼容下火狐(直接发回去收不到第一条消息:有待研究)
rsp := websocket_data.DataTransferData{
T: constants.WEBSOCKET_UNAUTH,
D: nil,
@ -111,9 +111,6 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request)
_ = conn.WriteMessage(websocket.CloseMessage, nil)
return
}
// todo user信息是没有的
/*var userInfo auth.UserInfo
userInfo.UserId = 39*/
//设置连接
ws := l.setConnPool(conn, *userInfo)
defer ws.close()
@ -156,7 +153,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User
mapConnPool.Store(uniqueId, ws)
go func() {
//把连接成功消息发回去
time.Sleep(time.Second * 1) //兼容下火狐
time.Sleep(time.Second * 1) //兼容下火狐(直接发回去收不到第一条消息:有待研究)
ws.sendToOutChan(ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, uniqueId))
}()
return ws