diff --git a/static/cosmopolite.js b/static/cosmopolite.js index 06eaf79..a64fe27 100644 --- a/static/cosmopolite.js +++ b/static/cosmopolite.js @@ -75,11 +75,6 @@ var Cosmopolite = function( */ this.shutdown_ = false; - /** - * @type {Array.} - * @private - */ - this.rpcQueue_ = []; /** * @type {Object.} * @private @@ -100,6 +95,9 @@ var Cosmopolite = function( localStorage[this.namespace_ + ':client_id'] = this.uuid_(); } + /** @type {string} */ + this.instanceID_ = this.uuid_(); + /** * @type {string} * @private @@ -728,12 +726,7 @@ Cosmopolite.prototype.sendRPC_ = function(command, args, opt_onSuccess) { 'arguments': args, 'onSuccess': opt_onSuccess || null }; - if (this.maySendRPC_()) { - this.sendRPCs_([rpc]); - } else { - // Queue instead of sending. - this.rpcQueue_.push(rpc); - } + this.sendRPCs_([rpc]); }; @@ -843,35 +836,14 @@ Cosmopolite.prototype.sendRPCs_ = function(commands, opt_delay) { }; -/** - * Are we currently clear to put RPCs on the wire? - * - * @return {boolean} - * @const - * @private - */ -Cosmopolite.prototype.maySendRPC_ = function() { - if (this.channelState_ != Cosmopolite.ChannelState_.OPEN) { - return false; - } - - return true; -}; - - /** * Handle tasks needed after reconnecting the channel * * @private */ Cosmopolite.prototype.onReconnect_ = function() { - if (!this.maySendRPC_()) { - return; - } - /** @type {Array.} */ - var rpcs = this.rpcQueue_; - this.rpcQueue_ = []; + var rpcs = []; for (var subject in this.subscriptions_) { /** @type {Cosmopolite.typeSubscription_} */ var subscription = this.subscriptions_[subject]; @@ -915,9 +887,6 @@ Cosmopolite.prototype.createChannel_ = function() { return; } - /** @type {string} */ - this.instanceID_ = this.uuid_(); - var rpcs = [ { 'command': 'createChannel', @@ -1015,6 +984,8 @@ Cosmopolite.prototype.onSocketClose_ = function() { }, this); } + this.instanceID_ = this.uuid_(); + this.createChannel_(); };