From 3477c7fad47ce8dae6b38bfe872ecaad72238ba6 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Thu, 26 Dec 2024 16:25:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E6=97=B6=E8=A7=86=E9=A2=91=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=89=88=E6=9C=AC2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/device.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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") }