From 3d0f035d4a276fd53b767e2be8b481a678a7360b Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Thu, 29 Oct 2020 04:47:25 +0100
Subject: [PATCH] Check server disconnect right on websocket.onclose.

---
 new2/rogue_chat_nocanvas_monochrome.html | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/new2/rogue_chat_nocanvas_monochrome.html b/new2/rogue_chat_nocanvas_monochrome.html
index 11fbfc6..fc5e24c 100644
--- a/new2/rogue_chat_nocanvas_monochrome.html
+++ b/new2/rogue_chat_nocanvas_monochrome.html
@@ -132,16 +132,15 @@ let server = {
         this.websocket = new WebSocket(url);
         this.websocket.onopen = function(event) {
             window.setInterval(function() { server.send(['PING']) }, 30000);
-            tui.log_msg("@ server connected!");
+            tui.log_msg("@ server connected! :)");
             tui.init_login();
         };
+        this.websocket.onclose = function(event) {
+            tui.log_msg('@ server disconnected :(');
+        }
     },
     send: function(tokens) {
-        if (this.websocket.readyState !== WebSocket.OPEN) {
-            tui.log_msg('server disconnected :(');
-        } else {
-            this.websocket.send(unparser.untokenize(tokens));
-        }
+        this.websocket.send(unparser.untokenize(tokens));
     }
 }
 
-- 
2.30.2