Showing IRC disconnections to the user #81
authorDarren <darren@Darrens-MacBook-Pro.local>
Mon, 20 May 2013 14:27:55 +0000 (15:27 +0100)
committerDarren <darren@Darrens-MacBook-Pro.local>
Mon, 20 May 2013 14:27:55 +0000 (15:27 +0100)
client/assets/dev/model_network.js
server/irc/state.js

index 3c0564491cc5c28803d0d302d93e6c6774d5b8cb..e43baa29bc9378de3d36c6323af23c5ce077f336 100644 (file)
@@ -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')) {
     });
 
 
+    
+    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;
index 4f3f764de839f58e3628dbc495c382e46387d1f1..bcd062ac27cf4d4cc0b47ade9debd8367c2760a4 100755 (executable)
@@ -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);
     });