Merge branch 'refs/heads/feature-im'
This commit is contained in:
commit
350a439f89
|
|
@ -175,6 +175,7 @@ func SRMessage(c *gin.Context) {
|
||||||
}
|
}
|
||||||
}(ws, res, to_user_id)
|
}(ws, res, to_user_id)
|
||||||
|
|
||||||
|
var status_cnt int
|
||||||
// 从Redis中读取消息并发送到客户端
|
// 从Redis中读取消息并发送到客户端
|
||||||
for {
|
for {
|
||||||
if v := clients[ws]; v == true {
|
if v := clients[ws]; v == true {
|
||||||
|
|
@ -206,12 +207,17 @@ func SRMessage(c *gin.Context) {
|
||||||
res3, _ = json.Marshal(msg)
|
res3, _ = json.Marshal(msg)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if status_cnt > 5 {
|
||||||
//对方不在线
|
//对方不在线
|
||||||
msg.Type = "offline"
|
msg.Type = "offline"
|
||||||
msg.Msg = "offline"
|
msg.Msg = "offline"
|
||||||
msg.From_user_id = -1
|
msg.From_user_id = -1
|
||||||
msg.Session = res
|
msg.Session = res
|
||||||
res3, _ = json.Marshal(msg)
|
res3, _ = json.Marshal(msg)
|
||||||
|
} else {
|
||||||
|
status_cnt++
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
err2 := ws.WriteMessage(websocket.TextMessage, res3)
|
err2 := ws.WriteMessage(websocket.TextMessage, res3)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue