automatically reconnect ws
This commit is contained in:
parent
3d87374e6c
commit
55cb005cbf
@ -1,5 +1,6 @@
|
|||||||
window.ws = new WebSocket("/custom/ws");
|
function openWebSocket() {
|
||||||
window.ws.onmessage = (e) => {
|
window.ws = new WebSocket("/custom/ws");
|
||||||
|
window.ws.onmessage = (e) => {
|
||||||
const msg = JSON.parse(e.data);
|
const msg = JSON.parse(e.data);
|
||||||
if ("ports" in msg) {
|
if ("ports" in msg) {
|
||||||
location.port = (location.protocol == "https:" ? msg.ports.https : msg.ports.http);
|
location.port = (location.protocol == "https:" ? msg.ports.https : msg.ports.http);
|
||||||
@ -10,7 +11,12 @@ window.ws.onmessage = (e) => {
|
|||||||
single.loadRoute("/webui/cheats");
|
single.loadRoute("/webui/cheats");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
window.ws.onclose = function() {
|
||||||
|
setTimeout(openWebSocket, 3000);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
openWebSocket();
|
||||||
|
|
||||||
let loginOrRegisterPending = false;
|
let loginOrRegisterPending = false;
|
||||||
window.registerSubmit = false;
|
window.registerSubmit = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user