增大发送sleep
This commit is contained in:
parent
385afc7b9c
commit
cd3c9a30ce
|
|
@ -234,6 +234,7 @@ func GetRealTimeImage(c *gin.Context) {
|
|||
go func(ws *websocket.Conn, device_id int) {
|
||||
|
||||
}(ws, device_id_int)
|
||||
var check_cnt int
|
||||
|
||||
for {
|
||||
if v := clients[ws]; v == true {
|
||||
|
|
@ -248,6 +249,12 @@ func GetRealTimeImage(c *gin.Context) {
|
|||
res3, _ = json.Marshal(msg)
|
||||
} else {
|
||||
//若无消息则发送心跳包
|
||||
if check_cnt < 5 {
|
||||
check_cnt++
|
||||
time.Sleep(time.Millisecond * 200) //设置延时200ms
|
||||
continue
|
||||
}
|
||||
check_cnt = 0
|
||||
msg.Type = "check"
|
||||
msg.Msg = "check"
|
||||
msg.From_user_id = -1
|
||||
|
|
@ -262,7 +269,7 @@ func GetRealTimeImage(c *gin.Context) {
|
|||
worker.SetRedisWithExpire(strconv.Itoa(int(device.ID))+"_is_play", "0", time.Minute*5) //设置播放状态
|
||||
break
|
||||
}
|
||||
time.Sleep(time.Millisecond * 100) //设置延时100ms
|
||||
time.Sleep(time.Millisecond * 200) //设置延时200ms
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue