mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Automatically reload page when WebSocket connection is closed
This commit is contained in:
parent
98c2f53a3a
commit
7d9b035e57
@ -27,7 +27,7 @@ class UserWebSocket {
|
|||||||
// Wait for connection
|
// Wait for connection
|
||||||
this.ws.addEventListener("open", () => console.log("Connected to websocket!"))
|
this.ws.addEventListener("open", () => console.log("Connected to websocket!"))
|
||||||
this.ws.addEventListener("error", (e) => this.Error(e))
|
this.ws.addEventListener("error", (e) => this.Error(e))
|
||||||
this.ws.addEventListener("close", (e) => this.Error(e));
|
this.ws.addEventListener("close", (e) => this.Closed(e));
|
||||||
|
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
this.Error(e);
|
this.Error(e);
|
||||||
@ -45,9 +45,14 @@ class UserWebSocket {
|
|||||||
/**
|
/**
|
||||||
* When we get disconnected from the websocket
|
* When we get disconnected from the websocket
|
||||||
*/
|
*/
|
||||||
static async Disconnected(e) {
|
static async Closed(e) {
|
||||||
console.error(e)
|
console.error("WS closed", e)
|
||||||
alert("Disconnected from the server !");
|
|
||||||
|
const num_seconds = ComunicWeb.__config.productionMode ? 5 : 0.5;
|
||||||
|
|
||||||
|
notify("Disconnected from the server, page will be reloaded in "+num_seconds+" seconds !", "danger");
|
||||||
|
|
||||||
|
setTimeout(() => ComunicWeb.common.system.restart(), num_seconds*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user