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