mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-22 09:46:30 -05:00
Fix to make socket keep retry after disconnect on server maintenance
This commit is contained in:
parent
e4555ed6fa
commit
5c8df4a7a1
1 changed files with 8 additions and 2 deletions
|
@ -1818,6 +1818,7 @@ socket.on('error', function (data) {
|
||||||
location.href = "./403";
|
location.href = "./403";
|
||||||
});
|
});
|
||||||
var retryOnDisconnect = false;
|
var retryOnDisconnect = false;
|
||||||
|
var retryTimer = null;
|
||||||
socket.on('maintenance', function (data) {
|
socket.on('maintenance', function (data) {
|
||||||
if (data == version)
|
if (data == version)
|
||||||
retryOnDisconnect = true;
|
retryOnDisconnect = true;
|
||||||
|
@ -1830,14 +1831,19 @@ socket.on('disconnect', function (data) {
|
||||||
}
|
}
|
||||||
if (!editor.getOption('readOnly'))
|
if (!editor.getOption('readOnly'))
|
||||||
editor.setOption('readOnly', true);
|
editor.setOption('readOnly', true);
|
||||||
if (retryOnDisconnect)
|
if (retryOnDisconnect && !retryTimer) {
|
||||||
socket.connect();
|
retryTimer = setInterval(function () {
|
||||||
|
socket.connect();
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
socket.on('reconnect', function (data) {
|
socket.on('reconnect', function (data) {
|
||||||
//sync back any change in offline
|
//sync back any change in offline
|
||||||
emitUserStatus(true);
|
emitUserStatus(true);
|
||||||
cursorActivity();
|
cursorActivity();
|
||||||
socket.emit('online users');
|
socket.emit('online users');
|
||||||
|
clearInterval(retryTimer);
|
||||||
|
retryTimer = null;
|
||||||
retryOnDisconnect = false;
|
retryOnDisconnect = false;
|
||||||
});
|
});
|
||||||
socket.on('connect', function (data) {
|
socket.on('connect', function (data) {
|
||||||
|
|
Loading…
Reference in a new issue