Update to retry when anytime the socket io disconnect

This commit is contained in:
Wu Cheng-Han 2016-10-23 21:43:18 +08:00
parent 223c0726cd
commit a42845cfc0

View file

@ -2308,11 +2308,9 @@ socket.on('delete', function () {
}); });
} }
}); });
var retryOnDisconnect = false;
var retryTimer = null; var retryTimer = null;
socket.on('maintenance', function () { socket.on('maintenance', function () {
cmClient.revision = -1; cmClient.revision = -1;
retryOnDisconnect = true;
}); });
socket.on('disconnect', function (data) { socket.on('disconnect', function (data) {
showStatus(statusType.offline); showStatus(statusType.offline);
@ -2322,7 +2320,7 @@ socket.on('disconnect', function (data) {
} }
if (!editor.getOption('readOnly')) if (!editor.getOption('readOnly'))
editor.setOption('readOnly', true); editor.setOption('readOnly', true);
if (retryOnDisconnect && !retryTimer) { if (!retryTimer) {
retryTimer = setInterval(function () { retryTimer = setInterval(function () {
if (!needRefresh) socket.connect(); if (!needRefresh) socket.connect();
}, 1000); }, 1000);
@ -2337,7 +2335,6 @@ socket.on('reconnect', function (data) {
socket.on('connect', function (data) { socket.on('connect', function (data) {
clearInterval(retryTimer); clearInterval(retryTimer);
retryTimer = null; retryTimer = null;
retryOnDisconnect = false;
personalInfo['id'] = socket.id; personalInfo['id'] = socket.id;
showStatus(statusType.connected); showStatus(statusType.connected);
socket.emit('version'); socket.emit('version');