From 9a8bdcb5baec8707748bf42041cb07fcea694329 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 26 Jul 2023 17:55:14 +0800 Subject: [PATCH] fix --- server/websocket/internal/logic/datatransferlogic.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index a606852a..88097476 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -193,15 +193,18 @@ func (w *wsConnectItem) readLoop() { case <-w.closeChan: //如果关闭了 return default: - _, data, err := w.conn.ReadMessage() + msgType, data, err := w.conn.ReadMessage() if err != nil { logx.Error("接受信息错误:", err) //关闭连接 w.close() return } - //消息传入缓冲通道 - w.inChan <- data + //ping的消息不处理 + if msgType != websocket.PingMessage { + //消息传入缓冲通道 + w.inChan <- data + } } } }