From c0e27205ac83d4eb9cae8fe62d385a65e0f2e7ef Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Wed, 18 May 2022 12:34:21 -0500 Subject: [PATCH] Add console print when ws close --- templates/chat/chat.html | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/templates/chat/chat.html b/templates/chat/chat.html index e1fb66d..9897d71 100644 --- a/templates/chat/chat.html +++ b/templates/chat/chat.html @@ -98,7 +98,7 @@ let META_HEADER = [ })} window.load_dynamic_update = function (last_msg) { - return new EventReceiver( + var receiver = EventReceiver( "{{ EVENT_DAEMON_LOCATION }}", "{{ EVENT_DAEMON_POLL_LOCATION }}", ['chat_lobby', 'chat_{{request.profile.id}}'], last_msg, function (message) { var room = (message.type == 'lobby') ? '' : message.room; @@ -110,6 +110,15 @@ let META_HEADER = [ } } ); + receiver.onwsclose = function (event) { + if (event.code == 1001) { + console.log('Navigated away'); + return; + } + console.log('You probably should refresh?'); + }; + + return receiver; } function refresh_status() {