diff --git a/views/game/index.html b/views/game/index.html index cb2bf400e50ceb5a246a7e06ca1fc5fbdefb3250..45e22c6a32030f991306bfd32745ca69ccaf7f3c 100644 --- a/views/game/index.html +++ b/views/game/index.html @@ -31,7 +31,9 @@ if ('WebSocket' in window) { var ws = new WebSocket("{{=GET_URL(room_record)}}"); - ws.onopen = function () {}; + ws.onopen = function () { + ws.initialConnect = true; + }; ws.onmessage = function(e) { set_info(e.data); render(name, role, JSON.parse(e.data)); @@ -40,7 +42,13 @@ set_error("{{=T('Error')}}: "+e); }; ws.onclose = function () { - set_error("{{=T('WebSocket has closed')}}. {{=T('Please refresh this website')}}."); + if(ws.initialConnect) { + window.setTimeout(function() { + set_error("{{=T('WebSocket has closed')}}. {{=T('Please refresh this website')}}."); + }, 1000); + } else { + set_error("{{=T('WebSocket server is not responding')}}."); + } }; } else { /* not supported */