This commit is contained in:
laodaming 2023-08-28 15:34:30 +08:00
parent fed40e2aa8
commit 083781737a

View File

@ -300,7 +300,7 @@ func (w *wsConnectItem) readLoop() {
select {
case <-w.closeChan: //如果关闭了
return
default:
default: //收取消息
msgType, data, err := w.conn.ReadMessage()
if err != nil {
logx.Error("接受信息错误:", err)
@ -310,8 +310,12 @@ func (w *wsConnectItem) readLoop() {
}
//ping的消息不处理
if msgType != websocket.PingMessage {
//消息传入缓冲通道
w.inChan <- data
select {
case w.inChan <- data: //消息传入缓冲通道
continue
case <-time.After(time.Second * 3): //3秒放不进去就丢弃
continue
}
}
}
}