From 5518103575f3f4cb53009d744630c41542adc490 Mon Sep 17 00:00:00 2001 From: Kato Twofold Date: Tue, 7 Jun 2022 01:44:48 +0300 Subject: [PATCH] * Cleanup --- static/js/ws.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/static/js/ws.js b/static/js/ws.js index 9d00703..0768410 100644 --- a/static/js/ws.js +++ b/static/js/ws.js @@ -51,9 +51,14 @@ class PadSocket { updateStatus(`Established`, `text-success`); } + function onFail() { + updateStatus(`Connection Failed`, `text-dangerous`); + setTimeout( connectSocket , 1000); + } + // Try and reconnect on failure - ws.onclose = connectSocket; - ws.onerror = connectSocket; + ws.onclose = onFail; + ws.onerror = onFail; // Assign the websocket this.ws = ws;