slamma jamma into instance when you first register
This commit is contained in:
+1
-13
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user