diff options
author | Cheng-Han, Wu | 2016-06-04 10:49:10 +0800 |
---|---|---|
committer | Cheng-Han, Wu | 2016-06-04 10:49:10 +0800 |
commit | 5c8df4a7a1e7206c897728c29a1c45936818a338 (patch) | |
tree | a6744e17a92145e93e02690d58e5d246ce14f132 /public | |
parent | e4555ed6fad9c9a774fe59cb3b0dc2c80ac3e0d7 (diff) |
Fix to make socket keep retry after disconnect on server maintenance
Diffstat (limited to '')
-rw-r--r-- | public/js/index.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/public/js/index.js b/public/js/index.js index 25c84ad9..d342e88a 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1818,6 +1818,7 @@ socket.on('error', function (data) { location.href = "./403"; }); var retryOnDisconnect = false; +var retryTimer = null; socket.on('maintenance', function (data) { if (data == version) retryOnDisconnect = true; @@ -1830,14 +1831,19 @@ socket.on('disconnect', function (data) { } if (!editor.getOption('readOnly')) editor.setOption('readOnly', true); - if (retryOnDisconnect) - socket.connect(); + if (retryOnDisconnect && !retryTimer) { + retryTimer = setInterval(function () { + socket.connect(); + }, 1000); + } }); socket.on('reconnect', function (data) { //sync back any change in offline emitUserStatus(true); cursorActivity(); socket.emit('online users'); + clearInterval(retryTimer); + retryTimer = null; retryOnDisconnect = false; }); socket.on('connect', function (data) { |