From 6847921a40989e06446a9230c2db8c21962293fe Mon Sep 17 00:00:00 2001 From: nokhnaton Date: Fri, 27 Oct 2023 18:29:36 +0900 Subject: [PATCH 1/2] =?UTF-8?q?reconnect=E3=81=AE=E6=9C=80=E5=B0=8F?= =?UTF-8?q?=E5=BE=85=E3=81=A1=E6=99=82=E9=96=93=E3=81=8CminReconnectionDel?= =?UTF-8?q?ay=E3=81=98=E3=82=83=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/websocket/AutoReconnectWebSocket.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/websocket/AutoReconnectWebSocket.ts b/src/lib/websocket/AutoReconnectWebSocket.ts index ad4f33589..ab2820bb4 100644 --- a/src/lib/websocket/AutoReconnectWebSocket.ts +++ b/src/lib/websocket/AutoReconnectWebSocket.ts @@ -145,9 +145,8 @@ export default class AutoReconnectWebSocket { let count = 0 while (!this.isOpen) { - count++ - const delay = this._getDelay(count) + count++ await wait(delay) if (this.isOpen) break From 0b61157d6586da5b8f469b8e748eb61d8c37e353 Mon Sep 17 00:00:00 2001 From: nokhnaton Date: Fri, 27 Oct 2023 18:35:07 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E3=83=9B=E3=83=BC=E3=83=A0=E7=94=BB?= =?UTF-8?q?=E9=9D=A2=E3=83=BB=E5=88=A5=E3=81=AE=E3=82=BF=E3=83=96=E3=83=BB?= =?UTF-8?q?=E5=88=A5=E3=81=AE=E3=82=A2=E3=83=97=E3=83=AA=E3=81=8B=E3=82=89?= =?UTF-8?q?=E6=88=BB=E3=81=A3=E3=81=9F=E3=81=A8=E3=81=8D=E3=81=AB=E3=80=81?= =?UTF-8?q?web=20socket=E3=82=92=E5=86=8D=E6=8E=A5=E7=B6=9A=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/websocket/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/websocket/index.ts b/src/lib/websocket/index.ts index b953de914..e1c1421e4 100644 --- a/src/lib/websocket/index.ts +++ b/src/lib/websocket/index.ts @@ -38,6 +38,12 @@ if (import.meta.env.MODE === 'development') { } } +document.addEventListener('visibilitychange', () => { + if (document.visibilityState === 'visible') { + ws.connect() + } +}) + export const wsListener = createWebSocketListener(ws) export const setupWebSocket = async () => {