From 34c8014c9571a716978c23b6523ca5f353bc3cde Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 5 Sep 2023 14:45:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96ws=E4=BB=A3=E7=A0=81=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/websocket/internal/logic/datatransferlogic.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 35f62ac4..4494a663 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -505,9 +505,13 @@ func (w *wsConnectItem) reciveBrowserMessage() { w.close() return } - //ping/pong/close的消息不处理 - if msgType != websocket.PingMessage && msgType != websocket.PongMessage && msgType != websocket.CloseMessage { + switch msgType { + case websocket.PingMessage, websocket.PongMessage: //心跳消息(过滤不处理) + continue + case websocket.BinaryMessage, websocket.TextMessage: //主要消息 w.sendToInChan(data) + case websocket.CloseMessage: //客户端主动关闭消息 + w.close() } } }