diff --git a/static/cosmopolite.js b/static/cosmopolite.js index 0ef5b63..4385e3c 100644 --- a/static/cosmopolite.js +++ b/static/cosmopolite.js @@ -676,8 +676,6 @@ Cosmopolite.prototype.sendRPCs_ = function(commands, delay) { return; } - this.flushRPCQueue_(); - // Handle events that were immediately available as if they came over the // channel. Fire them before the message callbacks, so clients can use // events like the subscribe promise fulfillment as a barrier for initial @@ -727,28 +725,19 @@ Cosmopolite.prototype.maySendRPC_ = function() { return true; } -/** - * Send queued RPCs - * - * @private - */ -Cosmopolite.prototype.flushRPCQueue_ = function() { - if (!this.maySendRPC_() || !this.rpcQueue_.length) { - return; - } - - this.sendRPCs_(this.rpcQueue_); - this.rpcQueue_ = []; -}; - /** * Handle tasks needed after reconnecting the channel * * @private */ Cosmopolite.prototype.onReconnect_ = function() { + if (!this.maySendRPC_()) { + return; + } + /** @type {Array.} */ - var rpcs = []; + var rpcs = this.rpcQueue_; + this.rpcQueue_ = []; for (var subject in this.subscriptions_) { /** @type {typeSubscription} */ var subscription = this.subscriptions_[subject]; @@ -856,7 +845,6 @@ Cosmopolite.prototype.onSocketOpen_ = function() { return; } - this.flushRPCQueue_(); this.onReconnect_(); };