Combining join, part, kick + quit client events into a single 'channel' event
authorDarren <darren@darrenwhitlen.com>
Sun, 1 Jun 2014 11:28:05 +0000 (12:28 +0100)
committerDarren <darren@darrenwhitlen.com>
Sun, 1 Jun 2014 11:28:05 +0000 (12:28 +0100)
client/src/models/gateway.js
client/src/models/network.js
server/irc/channel.js

index 4d8e49bb7b50fa337ad77acb821edd99348e065c..76ffeaf694faf1711a4771bfd746b2d546354a88 100644 (file)
@@ -232,6 +232,13 @@ _kiwi.model.Gateway = function () {
                     event_data: data\r
                 });\r
             }\r
+\r
+            if (command == 'channel' && data.type) {\r
+                that.trigger('connection:' + data.connection_id.toString(), {\r
+                    event_name: 'channel:' + data.type,\r
+                    event_data: data\r
+                });\r
+            }\r
         }\r
 \r
         // Trigger the global events\r
index f183fddfc595a5a606a17c341d3d1a3aad6e72d4..b90ad64717ec21133b6b75e6606c77849e7ea3c5 100644 (file)
 
             this.gateway.on('options', onOptions, this);
             this.gateway.on('motd', onMotd, this);
-            this.gateway.on('join', onJoin, this);
-            this.gateway.on('part', onPart, this);
-            this.gateway.on('quit', onQuit, this);
-            this.gateway.on('kick', onKick, this);
+            this.gateway.on('channel:join', onJoin, this);
+            this.gateway.on('channel:part', onPart, this);
+            this.gateway.on('channel:quit', onQuit, this);
+            this.gateway.on('channe:kick', onKick, this);
             this.gateway.on('message', onMessage, this);
             this.gateway.on('nick', onNick, this);
             this.gateway.on('ctcp_request', onCtcpRequest, this);
index 30d53ca1037777e3a398f48f03bc826be3952a69..b95dd1f1c1673e8870d531b4cbee9e01daed66d1 100644 (file)
@@ -54,7 +54,8 @@ function onJoin(event) {
         irc_event: event
     })
     .done(function() {
-        that.irc_connection.clientEvent('join', {
+        that.irc_connection.clientEvent('channel', {
+            type: 'join',
             channel: that.name,
             nick: event.nick,
             ident: event.ident,
@@ -74,7 +75,8 @@ function onPart(event) {
         irc_event: event
     })
     .done(function() {
-        that.irc_connection.clientEvent('part', {
+        that.irc_connection.clientEvent('channel', {
+            type: 'part',
             nick: event.nick,
             ident: event.ident,
             hostname: event.hostname,
@@ -95,7 +97,8 @@ function onKick(event) {
         irc_event: event
     })
     .done(function() {
-        that.irc_connection.clientEvent('kick', {
+        that.irc_connection.clientEvent('channel', {
+            type: 'kick',
             kicked: event.kicked,  // Nick of the kicked
             nick: event.nick, // Nick of the kicker
             ident: event.ident,
@@ -117,7 +120,8 @@ function onQuit(event) {
         irc_event: event
     })
     .done(function() {
-        that.irc_connection.clientEvent('quit', {
+        that.irc_connection.clientEvent('channel', {
+            type: 'quit',
             nick: event.nick,
             ident: event.ident,
             hostname: event.hostname,