修复实时查看

This commit is contained in:
junleea 2024-10-28 21:11:44 +08:00
parent 9a234f50fb
commit f53af2c097
1 changed files with 2 additions and 2 deletions

View File

@ -233,6 +233,7 @@ func subscribeAndHandleMessages(ws *websocket.Conn, device_id int) {
ctx := context.Background() ctx := context.Background()
pubsub := worker.RedisClient.Subscribe(ctx, strconv.Itoa(device_id)+"_frames_msgs") pubsub := worker.RedisClient.Subscribe(ctx, strconv.Itoa(device_id)+"_frames_msgs")
defer pubsub.Close() defer pubsub.Close()
defer ws.Close()
ch := pubsub.Channel() ch := pubsub.Channel()
var check_cnt int var check_cnt int
for msg := range ch { for msg := range ch {
@ -261,10 +262,9 @@ func subscribeAndHandleMessages(ws *websocket.Conn, device_id int) {
clientsMux.Lock() clientsMux.Lock()
clients[ws] = false clients[ws] = false
clientsMux.Unlock() clientsMux.Unlock()
ws.Close() fmt.Println("send message to client err:", err2)
worker.SetRedisWithExpire(strconv.Itoa(device_id)+"_is_play", "0", time.Minute*5) worker.SetRedisWithExpire(strconv.Itoa(device_id)+"_is_play", "0", time.Minute*5)
break break
} }
time.Sleep(time.Millisecond * 200)
} }
} }