mirror of https://github.com/calzoneman/sync.git
Omit the connection warning if the socket connected at least once before
This commit is contained in:
parent
6e772c6837
commit
5b9948f709
|
@ -6,6 +6,7 @@ Callbacks = {
|
||||||
|
|
||||||
/* fired when socket connection completes */
|
/* fired when socket connection completes */
|
||||||
connect: function() {
|
connect: function() {
|
||||||
|
HAS_CONNECTED_BEFORE = true;
|
||||||
SOCKETIO_CONNECT_ERROR_COUNT = 0;
|
SOCKETIO_CONNECT_ERROR_COUNT = 0;
|
||||||
$("#socketio-connect-error").remove();
|
$("#socketio-connect-error").remove();
|
||||||
socket.emit("joinChannel", {
|
socket.emit("joinChannel", {
|
||||||
|
@ -1034,6 +1035,7 @@ Callbacks = {
|
||||||
|
|
||||||
partitionChange: function (socketConfig) {
|
partitionChange: function (socketConfig) {
|
||||||
window.socket.disconnect();
|
window.socket.disconnect();
|
||||||
|
HAS_CONNECTED_BEFORE = false;
|
||||||
ioServerConnect(socketConfig);
|
ioServerConnect(socketConfig);
|
||||||
setupCallbacks();
|
setupCallbacks();
|
||||||
}
|
}
|
||||||
|
@ -1059,6 +1061,14 @@ setupCallbacks = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.on("connect_error", function (error) {
|
socket.on("connect_error", function (error) {
|
||||||
|
// If the socket has connected at least once during this
|
||||||
|
// session and now gets a connect error, it is likely because
|
||||||
|
// the server is down temporarily and not because of any configuration
|
||||||
|
// issue. Therefore, omit the warning message about refreshing.
|
||||||
|
if (HAS_CONNECTED_BEFORE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SOCKETIO_CONNECT_ERROR_COUNT++;
|
SOCKETIO_CONNECT_ERROR_COUNT++;
|
||||||
if (SOCKETIO_CONNECT_ERROR_COUNT >= 3 &&
|
if (SOCKETIO_CONNECT_ERROR_COUNT >= 3 &&
|
||||||
$("#socketio-connect-error").length === 0) {
|
$("#socketio-connect-error").length === 0) {
|
||||||
|
|
|
@ -66,6 +66,7 @@ var FILTER_FROM = 0;
|
||||||
var FILTER_TO = 0;
|
var FILTER_TO = 0;
|
||||||
var NO_STORAGE = typeof localStorage == "undefined" || localStorage === null;
|
var NO_STORAGE = typeof localStorage == "undefined" || localStorage === null;
|
||||||
var SOCKETIO_CONNECT_ERROR_COUNT = 0;
|
var SOCKETIO_CONNECT_ERROR_COUNT = 0;
|
||||||
|
var HAS_CONNECTED_BEFORE = false;
|
||||||
|
|
||||||
function getOpt(k) {
|
function getOpt(k) {
|
||||||
var v = NO_STORAGE ? readCookie(k) : localStorage.getItem(k);
|
var v = NO_STORAGE ? readCookie(k) : localStorage.getItem(k);
|
||||||
|
|
Loading…
Reference in New Issue