This commit is contained in:
laodaming 2023-07-25 19:37:56 +08:00
parent 3be83ed424
commit 59edb394fa

View File

@ -119,6 +119,7 @@ func (w *wsConnectItem) heartbeat() {
T: constants.WEBSOCKET_HEARTBEAT, T: constants.WEBSOCKET_HEARTBEAT,
D: "", D: "",
} }
b, _ := json.Marshal(rsp)
for { for {
time.Sleep(time.Second * 10) time.Sleep(time.Second * 10)
select { select {
@ -128,7 +129,6 @@ func (w *wsConnectItem) heartbeat() {
} }
//发送心跳信息 //发送心跳信息
b, _ := json.Marshal(rsp)
if err := w.conn.WriteMessage(websocket.TextMessage, b); err != nil { if err := w.conn.WriteMessage(websocket.TextMessage, b); err != nil {
logx.Error("发送心跳信息异常,关闭连接:", w.flag, err) logx.Error("发送心跳信息异常,关闭连接:", w.flag, err)
w.close() w.close()