// 0 = non-reconnecting state. 1 = reconnecting state.\r
var gw_stat = 0;\r
\r
- // If the current or upcoming disconnect was planned\r
- var unplanned_disconnect = false;\r
-\r
gw.on('disconnect', function (event) {\r
- unplanned_disconnect = !gw.disconnect_requested;\r
-\r
- if (unplanned_disconnect) {\r
- var msg = _kiwi.global.i18n.translate('client_models_application_reconnecting').fetch() + '...';\r
- that.message.text(msg, {timeout: 10000});\r
- }\r
-\r
that.view.$el.removeClass('connected');\r
\r
- // Mention the disconnection on every channel\r
- _kiwi.app.connections.forEach(function(connection) {\r
- connection.panels.server.addMsg('', styleText('quit', {text: msg}), 'action quit');\r
-\r
- connection.panels.forEach(function(panel) {\r
- if (!panel.isChannel())\r
- return;\r
-\r
- panel.addMsg('', styleText('quit', {text: msg}), 'action quit');\r
- });\r
- });\r
-\r
+ // Reconnection phase will start to kick in\r
gw_stat = 1;\r
});\r
\r
\r
gw.on('reconnecting', function (event) {\r
- var msg = _kiwi.global.i18n.translate('client_models_application_reconnect_in_x_seconds').fetch(event.delay/1000) + '...';\r
+ var msg = translateText('client_models_application_reconnect_in_x_seconds', [event.delay/1000]) + '...';\r
\r
// Only need to mention the repeating re-connection messages on server panels\r
_kiwi.app.connections.forEach(function(connection) {\r
\r
// After the socket has connected, kiwi handshakes and then triggers a kiwi:connected event\r
gw.on('kiwi:connected', function (event) {\r
+ var msg;\r
+\r
that.view.$el.addClass('connected');\r
- if (gw_stat !== 1) return;\r
\r
- if (unplanned_disconnect) {\r
- var msg = _kiwi.global.i18n.translate('client_models_application_reconnect_successfully').fetch() + ':)';\r
+ // If we were reconnecting, show some messages we have connected back OK\r
+ if (gw_stat === 1) {\r
+\r
+ // No longer in the reconnection state\r
+ gw_stat = 0;\r
+\r
+ msg = translateText('client_models_application_reconnect_successfully') + ' :)';\r
that.message.text(msg, {timeout: 5000});\r
- }\r
\r
- // Mention the re-connection on every channel\r
- _kiwi.app.connections.forEach(function(connection) {\r
- connection.reconnect();\r
+ // Mention the re-connection on every channel\r
+ _kiwi.app.connections.forEach(function(connection) {\r
+ connection.reconnect();\r
\r
- connection.panels.server.addMsg('', styleText('rejoin', {text: msg}), 'action join');\r
+ connection.panels.server.addMsg('', styleText('rejoin', {text: msg}), 'action join');\r
\r
- connection.panels.forEach(function(panel) {\r
- if (!panel.isChannel())\r
- return;\r
+ connection.panels.forEach(function(panel) {\r
+ if (!panel.isChannel())\r
+ return;\r
\r
- panel.addMsg('', styleText('rejoin', {text: msg}), 'action join');\r
+ panel.addMsg('', styleText('rejoin', {text: msg}), 'action join');\r
+ });\r
});\r
- });\r
+ }\r
\r
- gw_stat = 0;\r
});\r
})();\r
\r
if (data.force) {\r
// Get an interval between 5 and 6 minutes so everyone doesn't reconnect it all at once\r
var jump_server_interval = Math.random() * (360 - 300) + 300;\r
+ jump_server_interval = 1;\r
\r
// Tell the user we are going to disconnect, wait 5 minutes then do the actual reconnect\r
var msg = _kiwi.global.i18n.translate('client_models_application_jumpserver_prepare').fetch();\r