From: Darren Date: Sun, 23 Sep 2012 12:50:57 +0000 (+0100) Subject: Better disconnection/reconnection handling X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e8e30b572e7c97a9d9fee69e95e0d5c26583b0a5;p=KiwiIRC.git Better disconnection/reconnection handling --- diff --git a/client_backbone/dev/model_application.js b/client_backbone/dev/model_application.js index 6d01fa9..209e012 100755 --- a/client_backbone/dev/model_application.js +++ b/client_backbone/dev/model_application.js @@ -142,16 +142,36 @@ kiwi.model.Application = Backbone.Model.extend(new (function () { var gw_stat = 0; gw.on('disconnect', function (event) { - that.message.text('You have been disconnected. Attempting to reconnect..'); + var msg = 'You have been disconnected. Attempting to reconnect for you..'; + that.message.text(msg, {timeout: 10000}); + + // Mention the disconnection on every channel + $.each(kiwi.app.panels.models, function (idx, panel) { + console.log(arguments); + if (!panel || !panel.isChannel()) return; + panel.addMsg('', msg, 'action quit'); + }); + kiwi.app.panels.server.addMsg('', msg, 'action quit'); + gw_stat = 1; }); gw.on('reconnecting', function (event) { - that.message.text('You have been disconnected. Attempting to reconnect again in ' + (event.delay/1000) + ' seconds..'); + msg = 'You have been disconnected. Attempting to reconnect again in ' + (event.delay/1000) + ' seconds..'; + kiwi.app.panels.server.addMsg('', msg, 'action quit'); }); gw.on('connect', function (event) { if (gw_stat !== 1) return; - that.message.text('It\'s OK, you\'re connected again :)', {timeout: 5000}); + var msg = 'It\'s OK, you\'re connected again :)'; + that.message.text(msg, {timeout: 5000}); + + // Mention the disconnection on every channel + $.each(kiwi.app.panels.models, function (idx, panel) { + if (!panel || !panel.isChannel()) return; + panel.addMsg('', msg, 'action join'); + }); + kiwi.app.panels.server.addMsg('', msg, 'action join'); + gw_stat = 0; }); })();