diff --git a/handler/device.go b/handler/device.go index 06dccb6..b49911b 100644 --- a/handler/device.go +++ b/handler/device.go @@ -243,7 +243,7 @@ func subscribeAndHandleMessagesV2(ws *websocket.Conn, device_id int) { defer pubsub.Close() defer ws.Close() ch := pubsub.Channel() - var ticker *time.Ticker + var ticker *time.Ticker // 定时器, 用于发送心跳包, 防止连接断开,每秒发送一次 for { select { case msg, _ := <-ch: @@ -288,7 +288,7 @@ func subscribeAndHandleMessagesV2(ws *websocket.Conn, device_id int) { end: // 查看是否还有其他连接,没有则设置 is_play 为 0 if worker.IsContainKey(online_conn_key) == false { - worker.SetRedisWithExpire(strconv.Itoa(device_id)+"_is_play", "0", time.Minute*5) + worker.SetRedisWithExpire(strconv.Itoa(device_id)+"_is_play", "1", time.Minute*5) fmt.Println("device_id:", device_id, " has set is_play to 0") }