Reload page only if WebSocket was not gracefully closed

This commit is contained in:
Pierre HUBERT 2020-03-30 14:24:45 +02:00
parent 7d9b035e57
commit 4c5a608531

View File

@ -48,11 +48,17 @@ class UserWebSocket {
static async Closed(e) { static async Closed(e) {
console.error("WS closed", e) console.error("WS closed", e)
// Check if the server was gracefully stopped
if(!this.hasOwnProperty("ws"))
return;
const num_seconds = ComunicWeb.__config.productionMode ? 5 : 0.5; const num_seconds = ComunicWeb.__config.productionMode ? 5 : 0.5;
notify("Disconnected from the server, page will be reloaded in "+num_seconds+" seconds !", "danger"); notify("Disconnected from the server, page will be reloaded in "+num_seconds+" seconds !", "danger");
setTimeout(() => ComunicWeb.common.system.restart(), num_seconds*1000); setTimeout(() => {
ComunicWeb.common.system.restart();
}, num_seconds*1000);
} }
/** /**