From: Darren Date: Mon, 20 May 2013 14:27:55 +0000 (+0100) Subject: Showing IRC disconnections to the user #81 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a36b7eb63010c592a412a80211ff82f74a70ac6a;p=KiwiIRC.git Showing IRC disconnections to the user #81 --- diff --git a/client/assets/dev/model_network.js b/client/assets/dev/model_network.js index 3c05644..e43baa2 100644 --- a/client/assets/dev/model_network.js +++ b/client/assets/dev/model_network.js @@ -54,6 +54,7 @@ //this.gateway.on('all', function() {console.log('ALL', this.get('connection_id'), arguments);}); this.gateway.on('connect', onConnect, this); + this.gateway.on('disconnect', onDisconnect, this); this.gateway.on('nick', function(event) { if (event.nick === this.get('nick')) { @@ -131,6 +132,14 @@ }); + + function onDisconnect(event) { + $.each(this.panels.models, function (index, panel) { + panel.addMsg('', 'Disconnected from the IRC network', 'action quit'); + }); + } + + function onConnect(event) { var panels, channel_names; diff --git a/server/irc/state.js b/server/irc/state.js index 4f3f764..bcd062a 100755 --- a/server/irc/state.js +++ b/server/irc/state.js @@ -73,6 +73,9 @@ State.prototype.connect = function (hostname, port, ssl, nick, user, pass, callb }); con.on('close', function () { + // TODO: Can we get a better reason for the disconnection? Was it planned? + that.sendIrcCommand('disconnect', {server: con.con_num, reason: 'disconnected'}); + that.irc_connections[con_num] = null; global.servers.removeConnection(this); });