不在应用层发送心跳
This commit is contained in:
parent
6b235ba28c
commit
0f3001967c
|
|
@ -135,6 +135,7 @@ func subscribeAndHandleIMMessages(ws *websocket.Conn, userId int) {
|
|||
}()
|
||||
|
||||
go func() {
|
||||
defer close(done)
|
||||
//从redis订阅消息
|
||||
for m := range ch {
|
||||
msg := m.Payload // 获取消息,消息格式为json
|
||||
|
|
@ -152,11 +153,11 @@ func subscribeAndHandleIMMessages(ws *websocket.Conn, userId int) {
|
|||
}()
|
||||
|
||||
//发送心跳包
|
||||
//for {
|
||||
// select {
|
||||
// case <-done:
|
||||
// //客户端断开连接
|
||||
// return
|
||||
for {
|
||||
select {
|
||||
case <-done:
|
||||
//客户端断开连接
|
||||
return
|
||||
//case t := <-ticker.C:
|
||||
// //发送心跳
|
||||
// err := ws.WriteMessage(websocket.PingMessage, nil)
|
||||
|
|
@ -165,5 +166,6 @@ func subscribeAndHandleIMMessages(ws *websocket.Conn, userId int) {
|
|||
// return
|
||||
// }
|
||||
//}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue