fix: high CPU usage
This commit is contained in:
1 parent
2c0b0460c9
commit
20977a49f0
2 files changed
+37
-43
No files matched your search
@@ -5,21 +5,16 @@
|
||||
|
||||
var poll_interval = 2000;
|
||||
|
||||
var reload_upon_connect = () => {
|
||||
window.setTimeout(() => {
|
||||
var ws = new WebSocket(url);
|
||||
ws.onopen = () => window.location.reload();
|
||||
ws.onclose = reload_upon_connect;
|
||||
}, poll_interval);
|
||||
};
|
||||
|
||||
var ws = new WebSocket(url);
|
||||
|
||||
ws.onmessage = (ev) => {
|
||||
ws.addEventListener("message", (ev) => {
|
||||
if (ev.data == "reload") {
|
||||
window.location.reload();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
ws.addEventListener("open", () => {
|
||||
ws.send("init");
|
||||
});
|
||||
|
||||
ws.onclose = reload_upon_connect;
|
||||
})();
|
||||
Reference in new issue
Block a user