slamma jamma into instance when you first register

This commit is contained in:
ntr
2019-11-11 14:00:23 +11:00
parent eb51cad036
commit 61a8db708b
3 changed files with 28 additions and 13 deletions
+1 -13
View File
@@ -318,11 +318,8 @@ function createSocket(events) {
return handlers[msgType](params);
}
let attempts = 1;
// Connection opened
function onOpen() {
attempts = 0;
toast.info({
message: 'connected',
position: 'topRight',
@@ -341,21 +338,12 @@ function createSocket(events) {
}
function onClose(event) {
attempts *= 2;
if (attempts > 10) {
toast.warning({
message: 'unable to connect, refreshing...',
position: 'topRight',
});
setTimeout(() => window.location.reload(true), 2000);
}
console.error('WebSocket closed', event);
toast.warning({
message: 'disconnected',
position: 'topRight',
});
return setTimeout(connect, attempts * 1000);
return setTimeout(connect, 2000);
}
function connect() {