Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/scsocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var SCSocket = function (options) {

this.id = null;
this.state = this.CLOSED;
this.pendingConnectCallback = false;

this.ackTimeout = opts.ackTimeout;

Expand Down Expand Up @@ -378,6 +379,8 @@ SCSocket.prototype._onSCOpen = function (status) {
this._connectAttempts = 0;
if (this.options.autoProcessSubscriptions) {
this.processPendingSubscriptions();
} else {
this.pendingConnectCallback = true;
}

// If the user invokes the callback while in autoProcessSubscriptions mode, it
Expand Down Expand Up @@ -591,7 +594,7 @@ SCSocket.prototype._trySubscribe = function (channel) {
var self = this;

// We can only ever have one pending subscribe action at any given time on a channel
if (this.state == this.OPEN && channel._pendingSubscriptionCid == null) {
if (this.state == this.OPEN && !this.pendingConnectCallback && channel._pendingSubscriptionCid == null) {
var options = {
noTimeout: true
};
Expand Down Expand Up @@ -725,6 +728,8 @@ SCSocket.prototype.isSubscribed = function (channel, includePending) {
SCSocket.prototype.processPendingSubscriptions = function () {
var self = this;

this.pendingConnectCallback = false;

var channels = [];
for (var channelName in this._channels) {
if (this._channels.hasOwnProperty(channelName)) {
Expand Down