Trigger message:* channel:* events for global Network() object
authorDarren <darren@darrenwhitlen.com>
Wed, 16 Jul 2014 21:40:02 +0000 (22:40 +0100)
committerDarren <darren@darrenwhitlen.com>
Wed, 16 Jul 2014 21:40:02 +0000 (22:40 +0100)
client/src/models/gateway.js

index 01f92e8f013ef954b4559f61f1ba263abd4f9c38..d5af31f249288cafe2cbd8188fae556d0c513b7d 100644 (file)
@@ -217,24 +217,27 @@ _kiwi.model.Gateway = function () {
     *   Parses the response from the server\r
     */\r
     this.parse = function (command, data) {\r
+        var network_trigger = '';\r
 \r
         // Trigger the connection specific events (used by Network objects)\r
         if (typeof data.connection_id !== 'undefined') {\r
-            that.trigger('connection:' + data.connection_id.toString(), {\r
+            network_trigger = 'connection:' + data.connection_id.toString();\r
+\r
+            that.trigger(network_trigger, {\r
                 event_name: command,\r
                 event_data: data\r
             });\r
 \r
             // Some events trigger a more in-depth event name\r
             if (command == 'message' && data.type) {\r
-                that.trigger('connection:' + data.connection_id.toString(), {\r
+                that.trigger('connection ' + network_trigger, {\r
                     event_name: 'message:' + data.type,\r
                     event_data: data\r
                 });\r
             }\r
 \r
             if (command == 'channel' && data.type) {\r
-                that.trigger('connection:' + data.connection_id.toString(), {\r
+                that.trigger('connection ' + network_trigger, {\r
                     event_name: 'channel:' + data.type,\r
                     event_data: data\r
                 });\r