feat(webui): initial websocket integration to be more responsive #2221

Merged
Sainan merged 4 commits from ws into main 2025-06-20 14:00:57 -07:00
Showing only changes of commit 55cb005cbf - Show all commits

View File

@ -1,16 +1,22 @@
window.ws = new WebSocket("/custom/ws"); function openWebSocket() {
window.ws.onmessage = (e) => { window.ws = new WebSocket("/custom/ws");
const msg = JSON.parse(e.data); window.ws.onmessage = (e) => {
if ("ports" in msg) { const msg = JSON.parse(e.data);
location.port = (location.protocol == "https:" ? msg.ports.https : msg.ports.http); if ("ports" in msg) {
} location.port = (location.protocol == "https:" ? msg.ports.https : msg.ports.http);
if ("config_reloaded" in msg) {
//window.is_admin = undefined;
if (single.getCurrentPath() == "/webui/cheats") {
single.loadRoute("/webui/cheats");
} }
} if ("config_reloaded" in msg) {
}; //window.is_admin = undefined;
if (single.getCurrentPath() == "/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;