* Handle the reconnections to the kiwi server\r
*/\r
(function () {\r
+ // 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
that.message.text(msg, {timeout: 5000});\r
}\r
\r
- // Mention the disconnection on every channel\r
+ // Mention the re-connection on every channel\r
_kiwi.app.connections.forEach(function(connection) {\r
connection.panels.server.addMsg('', msg, 'action join');\r
\r
\r
\r
gw.on('kiwi:jumpserver', function (data) {\r
- // Switching kiwi server?\r
- if (typeof data.kiwi_server !== 'undefined') {\r
- _kiwi.app.kiwi_server = data.kiwi_server;\r
- _kiwi.gateway.set('kiwi_server', data.kiwi_server);\r
- }\r
+ var serv;\r
+ // No server set? Then nowhere to jump to.\r
+ if (typeof data.kiwi_server === 'undefined')\r
+ return;\r
+\r
+ serv = data.kiwi_server;\r
+\r
+ // Strip any trailing slash from the end\r
+ if (serv[serv.length-1] === '/')\r
+ serv = serv.substring(0, serv.length-1);\r
+\r
+ _kiwi.app.kiwi_server = serv;\r
\r
// Force the jumpserver now?\r
if (data.force) {\r
// Get an interval around 1 minute so everyone doesn't reconnect it all at once\r
var jump_server_interval = Math.random() * (90 - 60) + 60;\r
\r
+ // Tell the user we are going to disconnect, wait a minute then do the actual reconnect\r
var msg = _kiwi.global.i18n.translate('client_models_application_jumpserver_prepare').fetch();\r
that.message.text(msg, {timeout: 10000});\r
\r
that.message.text(msg, {timeout: 8000});\r
\r
setTimeout(function forcedReconnectPartTwo() {\r
- _kiwi.gateway.reconnect();\r
+ _kiwi.gateway.reconnect(function() {\r
+ // Reconnect all the IRC connections\r
+ that.connections.forEach(function(con){ con.reconnect(); });\r
+ });\r
}, 5000);\r
\r
}, jump_server_interval * 1000);\r