From: Christian Heller Date: Thu, 10 Dec 2020 20:25:23 +0000 (+0100) Subject: In web client, only reconnect if websocket.readyState != 1. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7Bprefix%7D%7D/te"st.html?a=commitdiff_plain;h=f519c96298473525a7bb006e9ef7efa34cb43a46;p=plomrogue2 In web client, only reconnect if websocket.readyState != 1. This eliminates a bug where the client's reconnect impatience would never allow a connection to be established, if the server was too busy. --- diff --git a/rogue_chat.html b/rogue_chat.html index ebe64f2..1b62a81 100644 --- a/rogue_chat.html +++ b/rogue_chat.html @@ -454,7 +454,6 @@ let server = { this.url = url; this.websocket = new WebSocket(this.url); this.websocket.onopen = function(event) { - server.connected = true; game.thing_types = {}; game.terrains = {}; server.send(['TASKS']); @@ -464,7 +463,6 @@ let server = { tui.switch_mode('login'); }; this.websocket.onclose = function(event) { - server.connected = false; tui.switch_mode('waiting_for_server'); tui.log_msg("@ server disconnected :("); }; @@ -1660,13 +1658,13 @@ for (let key_selector of key_selectors) { }, false); } window.setInterval(function() { - if (server.connected) { + if (server.websocket.readyState == 1) { server.send(['PING']); } else { server.reconnect_to(server.url); tui.log_msg('@ attempting reconnect …') } -}, 5000); +}, 1000); window.setInterval(function() { let val = "?"; let span_decoration = "none";