This commit is contained in:
laodaming 2023-07-26 18:03:27 +08:00
parent fdaddf9184
commit 265fd81b27

View File

@ -106,7 +106,7 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp
rsp.T = constants.WEBSOCKET_CONNECT_SUCCESS
rsp.D = flag
b, _ := json.Marshal(rsp)
conn.WriteMessage(websocket.TextMessage, b)
_ = conn.WriteMessage(websocket.TextMessage, b)
//循环读客户端信息
go ws.readLoop()
//循环把数据发送给客户端
@ -181,7 +181,11 @@ func (w *wsConnectItem) writeLoop() {
case <-w.closeChan: //如果关闭了
return
case data := <-w.outChan:
w.conn.WriteMessage(websocket.TextMessage, data)
if err := w.conn.WriteMessage(websocket.TextMessage, data); err != nil {
logx.Error("websocket write loop err:", err)
w.close()
return
}
}
}
}