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