优化ws代码结构

This commit is contained in:
laodaming 2023-09-05 14:45:15 +08:00
parent a3c1b12078
commit 34c8014c95

View File

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