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() } } }