From 8cc59dbe6d96e57791241d5286496e0ab582e492 Mon Sep 17 00:00:00 2001 From: Darren Date: Sat, 8 Feb 2014 21:05:14 +0000 Subject: [PATCH] Connection issues fix #472 --- client/src/models/gateway.js | 11 +++++++++-- server/client.js | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/client/src/models/gateway.js b/client/src/models/gateway.js index 753bc02..7ee21fa 100644 --- a/client/src/models/gateway.js +++ b/client/src/models/gateway.js @@ -151,6 +151,8 @@ _kiwi.model.Gateway = function () { * @param {Function} callback A callback function to be invoked once Kiwi's server has connected to the IRC server */ this.connect = function (callback) { + this.connect_callback = callback; + // Keep note of the server we are connecting to this.set('kiwi_server', _kiwi.app.kiwi_server); @@ -188,8 +190,6 @@ _kiwi.model.Gateway = function () { that.disconnect_requested = false; console.log("_kiwi.gateway.socket.on('open')"); - - callback && callback(); }); this.rpc.on('too_many_connections', function () { @@ -294,6 +294,13 @@ _kiwi.model.Gateway = function () { this.parseKiwi = function (command, data) { this.trigger('kiwi:' + command, data); this.trigger('kiwi', data); + + switch (command) { + case 'connected': + this.connect_callback && this.connect_callback(); + delete this.connect_callback; + break; + } }; /* Events: diff --git a/server/client.js b/server/client.js index b8e7faf..d41dc52 100755 --- a/server/client.js +++ b/server/client.js @@ -49,6 +49,9 @@ var Client = function (websocket) { }); this.disposed = false; + + // Let the client know it's finished connecting + this.sendKiwiCommand('connected'); }; util.inherits(Client, events.EventEmitter); -- 2.25.1