Better disconnection/reconnection handling
authorDarren <darren@darrenwhitlen.com>
Sun, 23 Sep 2012 12:50:57 +0000 (13:50 +0100)
committerDarren <darren@darrenwhitlen.com>
Sun, 23 Sep 2012 12:50:57 +0000 (13:50 +0100)
client_backbone/dev/model_application.js

index 6d01fa9829224fdedd1c80a165efac35daeb40e0..209e012bd1d3ded4f18655a04c1a664e5002be1e 100755 (executable)
@@ -142,16 +142,36 @@ kiwi.model.Application = Backbone.Model.extend(new (function () {
             var gw_stat = 0;\r
 \r
             gw.on('disconnect', function (event) {\r
-                that.message.text('You have been disconnected. Attempting to reconnect..');\r
+                var msg = 'You have been disconnected. Attempting to reconnect for you..';\r
+                that.message.text(msg, {timeout: 10000});\r
+\r
+                // Mention the disconnection on every channel\r
+                $.each(kiwi.app.panels.models, function (idx, panel) {\r
+                    console.log(arguments);\r
+                    if (!panel || !panel.isChannel()) return;\r
+                    panel.addMsg('', msg, 'action quit');\r
+                });\r
+                kiwi.app.panels.server.addMsg('', msg, 'action quit');\r
+\r
                 gw_stat = 1;\r
             });\r
             gw.on('reconnecting', function (event) {\r
-                that.message.text('You have been disconnected. Attempting to reconnect again in ' + (event.delay/1000) + ' seconds..');\r
+                msg = 'You have been disconnected. Attempting to reconnect again in ' + (event.delay/1000) + ' seconds..';\r
+                kiwi.app.panels.server.addMsg('', msg, 'action quit');\r
             });\r
             gw.on('connect', function (event) {\r
                 if (gw_stat !== 1) return;\r
 \r
-                that.message.text('It\'s OK, you\'re connected again :)', {timeout: 5000});\r
+                var msg = 'It\'s OK, you\'re connected again :)';\r
+                that.message.text(msg, {timeout: 5000});\r
+\r
+                // Mention the disconnection on every channel\r
+                $.each(kiwi.app.panels.models, function (idx, panel) {\r
+                    if (!panel || !panel.isChannel()) return;\r
+                    panel.addMsg('', msg, 'action join');\r
+                });\r
+                kiwi.app.panels.server.addMsg('', msg, 'action join');\r
+\r
                 gw_stat = 0;\r
             });\r
         })();\r