Implement reconnection during account loading
This commit is contained in:
parent
49df598d7d
commit
6615a7db65
2 changed files with 8 additions and 0 deletions
|
@ -77,6 +77,7 @@ function loadAccount() {
|
||||||
fileReader.addEventListener('load', function() {
|
fileReader.addEventListener('load', function() {
|
||||||
Save.set(null, JSON.parse(fileReader.result));
|
Save.set(null, JSON.parse(fileReader.result));
|
||||||
var name = restoreName();
|
var name = restoreName();
|
||||||
|
Messaging.reset();
|
||||||
if(name != undefined) {
|
if(name != undefined) {
|
||||||
Session.start(name);
|
Session.start(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ init();
|
||||||
return {
|
return {
|
||||||
addEventListener: addEventListener,
|
addEventListener: addEventListener,
|
||||||
isOn: isOn,
|
isOn: isOn,
|
||||||
|
reset: reset,
|
||||||
send: send
|
send: send
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -136,3 +137,9 @@ function ping() {
|
||||||
}
|
}
|
||||||
}, keepAlivePeriod * s);
|
}, keepAlivePeriod * s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reset() {
|
||||||
|
on = false; // this should be handled by the close event but when other operations are performed right after the reset, the event might not have had time to fire and the other functions, in particular send(), will assume the socket is still open and fail to actually send them instead of gently queueing them for when connectivity goes back up
|
||||||
|
reconnectDelay = 0.125; // since we're forcing the connection to close, there's no reason to assume the server went down so we manually lower the reconnectDelay to make the reconnection more fluid (there's no point making the user wait the usual 1 s. and the worse that could happen is we overflow the server a little with 3 connection attempts in 1 s.)
|
||||||
|
ws.close();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue