1
This commit is contained in:
parent
b03f87c919
commit
bb8c80d7f7
|
@ -310,12 +310,7 @@ func (w *wsConnectItem) readLoop() {
|
|||
}
|
||||
//ping/pong/close的消息不处理
|
||||
if msgType != websocket.PingMessage && msgType != websocket.PongMessage && msgType != websocket.CloseMessage {
|
||||
select {
|
||||
case w.inChan <- data: //消息传入缓冲通道
|
||||
continue
|
||||
case <-time.After(time.Second * 3): //3秒放不进去就丢弃
|
||||
continue
|
||||
}
|
||||
w.sendToInChan(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -350,6 +345,18 @@ func (w *wsConnectItem) sendToOutChan(data []byte) {
|
|||
}
|
||||
}
|
||||
|
||||
// 发送接受到的消息到入口缓冲队列中
|
||||
func (w *wsConnectItem) sendToInChan(data []byte) {
|
||||
select {
|
||||
case <-w.closeChan: //关闭了
|
||||
return
|
||||
case w.inChan <- data:
|
||||
return
|
||||
case <-time.After(time.Second * 3): //3秒超时丢弃
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 格式化为websocket标准返回格式
|
||||
func (w *wsConnectItem) respondDataFormat(msgType constants.Websocket, data interface{}) []byte {
|
||||
d := websocket_data.DataTransferData{
|
||||
|
|
Loading…
Reference in New Issue
Block a user