From 52ef084c2403a6f3a3fbfe77a7ef375d68b01e61 Mon Sep 17 00:00:00 2001 From: srcrs Date: Wed, 9 Aug 2023 22:07:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=87=8D=E8=BF=9E=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E4=B8=BA5=E5=88=86=E9=92=9F=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=8F=91=E9=80=81=E5=BF=83=E8=B7=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index d04b9f3..c3ae007 100644 --- a/index.html +++ b/index.html @@ -130,8 +130,16 @@ }; socket.onclose = event => { console.log("WebSocket closed. Reconnecting..."); - setTimeout(connect, 120000); + setTimeout(connect, 300000); }; + // Send heartbeat message every 120 seconds + const sendHeartbeat = () => { + if (socket.readyState === WebSocket.OPEN) { + socket.send("heartbeat"); + } + console.log(socket.readyState); + }; + setInterval(sendHeartbeat, 120000); }; connect(); },