From df8772812aa1927bb7a180aef0b30dfb9c3c9df1 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 10 Aug 2023 19:42:31 +0800 Subject: [PATCH] fix --- server/websocket/internal/logic/datatransferlogic.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index cbd1a189..825ce08a 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -114,12 +114,6 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp userInfo.UserId = 39 ws := l.setConnPool(conn, userInfo) defer ws.close() - go func() { - //把连接成功消息发回去 - time.Sleep(time.Second * 2) //兼容下火狐 - b := ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, uniqueId) - _ = conn.WriteMessage(websocket.TextMessage, b) - }() //循环读客户端信息 go ws.readLoop() //循环把数据发送给客户端 @@ -156,6 +150,12 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User } //保存连接 mapConnPool.Store(uniqueId, ws) + go func() { + //把连接成功消息发回去 + time.Sleep(time.Second * 2) //兼容下火狐 + b := ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, uniqueId) + _ = conn.WriteMessage(websocket.TextMessage, b) + }() return ws } func (l *DataTransferLogic) getUniqueId() string {