Cleaning up existing WebsocketRpc instances on reconnect
authorDarren <darren@darrenwhitlen.com>
Fri, 19 Sep 2014 13:34:22 +0000 (14:34 +0100)
committerDarren <darren@darrenwhitlen.com>
Fri, 19 Sep 2014 13:34:22 +0000 (14:34 +0100)
client/src/models/gateway.js

index a8d8f1af3fbdf72892c662bf440814a952db8bfa..7fe7cf3bdd489e26f8c8b44f32e1fccd6cd4a533 100644 (file)
@@ -40,6 +40,10 @@ _kiwi.model.Gateway = Backbone.Model.extend({
             reconnect_delay: 2000\r
         });\r
 \r
+        // If we have an existing RPC object, clean it up before replacing it\r
+        if (this.rpc) {\r
+            rpc.dispose();\r
+        }\r
         this.rpc = new EngineioTools.Rpc(this.socket);\r
 \r
         this.socket.on('connect_failed', function (reason) {\r