Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

socketcluster-client

Package Overview
Dependencies
Maintainers
1
Versions
236
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

socketcluster-client - npm Package Compare versions

Comparing version 1.3.6 to 1.3.7

113

lib/scsocket.js

@@ -193,2 +193,4 @@ var Emitter = require('emitter');

if (this.state == this.CLOSED) {
this._clearAllSocketBindings();
this.state = this.CONNECTING;

@@ -206,15 +208,23 @@

socket.on('open', function () {
self._onSCOpen(socket);
if (socket == self.socket) {
self._onSCOpen();
}
});
socket.on('error', function (err) {
self._onSCError(err);
if (socket == self.socket) {
self._onSCError(err);
}
});
socket.on('close', function () {
self._onSCClose(socket, self.RECONNECT_DELAYED);
if (socket == self.socket) {
self._onSCClose(self.RECONNECT_DELAYED);
}
});
socket.on('message', function (message) {
self._onSCMessage(socket, message);
if (socket == self.socket) {
self._onSCMessage(message);
}
});

@@ -226,3 +236,3 @@ }

if (this.state == this.OPEN) {
this._onSCClose(this.socket);
this._onSCClose();
this.socket.close();

@@ -236,3 +246,3 @@ }

SCSocket.prototype._onSCOpen = function (socket) {
SCSocket.prototype._onSCOpen = function () {
var self = this;

@@ -248,6 +258,6 @@

this._resubscribe(socket);
this._resubscribe();
Emitter.prototype.emit.call(this, 'connect');
this._flushEmitBuffer(socket);
this._flushEmitBuffer();

@@ -258,3 +268,3 @@ clearTimeout(this._initTimeoutTicker);

this._initTimeoutTicker = setTimeout(function () {
socket.close();
self.socket.close();
var error = new Error("Client socket initialization timed out - Client did not receive a 'ready' event");

@@ -264,3 +274,3 @@ error.type = 'timeout';

self._onSCError(error);
self._onSCClose(socket, self.RECONNECT_DELAYED);
self._onSCClose(self.RECONNECT_DELAYED);
}, this.initTimeout);

@@ -324,2 +334,8 @@ };

SCSocket.prototype._clearAllSocketBindings = function (code, data) {
clearTimeout(this._initTimeoutTicker);
clearTimeout(this._reconnectTimeout);
clearInterval(this._alreadyReceivedCleanupInterval);
};
// The reconnect argument can be:

@@ -329,4 +345,4 @@ // RECONNECT_IMMEDIATE: 'immediate'

// or null (no reconnect)
SCSocket.prototype._onSCClose = function (socket, reconnect) {
clearInterval(this._alreadyReceivedCleanupInterval);
SCSocket.prototype._onSCClose = function (reconnect) {
this._clearAllSocketBindings();
this._alreadyReceivedManager.clear();

@@ -342,2 +358,3 @@

var socket = this.socket;
socket.removeListener('open');

@@ -387,3 +404,3 @@ socket.removeListener('error');

SCSocket.prototype._onSCMessage = function (socket, message) {
SCSocket.prototype._onSCMessage = function (message) {
Emitter.prototype.emit.call(this, 'message', message);

@@ -480,3 +497,3 @@

} else if (obj.event == 'pingTimeout') {
this._onSCClose(socket, this.RECONNECT_IMMEDIATE);
this._onSCClose(this.RECONNECT_IMMEDIATE);
} else {

@@ -489,3 +506,3 @@ var response = new Response(this, obj.cid);

} else if (obj.disconnect) {
this._onSCClose(socket);
this._onSCClose();
} else if (obj.rid != null) {

@@ -583,25 +600,17 @@ var ret = this._callbackMap[obj.rid];

SCSocket.prototype._send = function (socket, data, options) {
if (!socket || socket.readyState != this.OPEN) {
SCSocket.prototype.send = function (data, options) {
if (this.socket.readyState != this.OPEN) {
var error = new Error('Failed to send - Underlying connection was not open');
this._onSCError(error);
this._onSCClose(socket, this.RECONNECT_DELAYED);
this._onSCClose(this.RECONNECT_DELAYED);
} else {
socket.send(data, options);
this.socket.send(data, options);
}
};
SCSocket.prototype._sendObject = function (socket, object, options) {
this._send(socket, this.stringify(object), options);
};
SCSocket.prototype.send = function (data, options) {
this._send(this.socket, data, options);
};
SCSocket.prototype.sendObject = function (object, options) {
this._sendObject(this.socket, object, options);
this.send(this.stringify(object), options);
};
SCSocket.prototype._emitRaw = function (socket, eventObject) {
SCSocket.prototype._emitRaw = function (eventObject) {
eventObject.cid = this._nextCallId();

@@ -619,6 +628,6 @@

this._sendObject(socket, simpleEventObject);
this.sendObject(simpleEventObject);
};
SCSocket.prototype._flushEmitBuffer = function (socket) {
SCSocket.prototype._flushEmitBuffer = function () {
var currentNode = this._emitBuffer.head;

@@ -631,3 +640,3 @@ var nextNode;

currentNode.detach();
this._emitRaw(socket, eventObject);
this._emitRaw(eventObject);
currentNode = nextNode;

@@ -659,3 +668,3 @@ }

// The last two optional arguments (a and b) can be options and/or callback
SCSocket.prototype._emitDirect = function (socket, event, data, a, b) {
SCSocket.prototype._emitDirect = function (event, data, a, b) {
var self = this;

@@ -695,10 +704,10 @@

if (this.state == this.OPEN) {
this._emitRaw(socket, eventObject);
this._emitRaw(eventObject);
}
};
SCSocket.prototype._emit = function (socket, event, data, callback) {
SCSocket.prototype._emit = function (event, data, callback) {
var self = this;
if (this.state == this.CLOSED || socket.readyState == socket.CLOSED) {
if (this.state == this.CLOSED) {
this.connect();

@@ -724,3 +733,3 @@ }

if (this.state == this.OPEN) {
this._flushEmitBuffer(socket);
this._flushEmitBuffer();
}

@@ -731,3 +740,3 @@ };

if (this._localEvents[event] == null) {
this._emit(this.socket, event, data, callback);
this._emit(event, data, callback);
} else {

@@ -765,3 +774,3 @@ Emitter.prototype.emit.call(this, event, data);

SCSocket.prototype._retrySubscribe = function (socket, channel) {
SCSocket.prototype._retrySubscribe = function (channel) {
var self = this;

@@ -786,3 +795,3 @@

if (channel.state == channel.PENDING) {
self._trySubscribe(socket, channel);
self._trySubscribe(channel);
}

@@ -793,3 +802,3 @@ }, timeout);

SCSocket.prototype._trySubscribe = function (socket, channel) {
SCSocket.prototype._trySubscribe = function (channel) {
var self = this;

@@ -801,6 +810,6 @@

};
this._emitDirect(socket, 'subscribe', channel.name, options, function (err) {
this._emitDirect('subscribe', channel.name, options, function (err) {
if (err) {
if (err.type == 'timeout') {
self._retrySubscribe(socket, channel);
self._retrySubscribe(channel);
} else {

@@ -830,3 +839,3 @@ self._triggerChannelSubscribeFail(err, channel);

channel.subscribeAttempts = 0;
this._trySubscribe(this.socket, channel);
this._trySubscribe(channel);
}

@@ -837,3 +846,3 @@

SCSocket.prototype._retryUnsubscribe = function (socket, channel) {
SCSocket.prototype._retryUnsubscribe = function (channel) {
var self = this;

@@ -859,3 +868,3 @@

if (channel.state == channel.UNSUBSCRIBED) {
self._tryUnsubscribe(socket, channel);
self._tryUnsubscribe(channel);
}

@@ -866,3 +875,3 @@ }, timeout);

SCSocket.prototype._tryUnsubscribe = function (socket, channel) {
SCSocket.prototype._tryUnsubscribe = function (channel) {
var self = this;

@@ -874,5 +883,5 @@

};
this._emitDirect(socket, 'unsubscribe', channel.name, options, function (err) {
this._emitDirect('unsubscribe', channel.name, options, function (err) {
if (err) {
self._retryUnsubscribe(socket, channel);
self._retryUnsubscribe(channel);
} else {

@@ -895,3 +904,3 @@ channel.unsubscribeAttempts = 0;

channel.unsubscribeAttempts = 0;
this._tryUnsubscribe(this.socket, channel);
this._tryUnsubscribe(channel);
}

@@ -986,3 +995,3 @@ }

SCSocket.prototype._resubscribe = function (socket) {
SCSocket.prototype._resubscribe = function () {
var self = this;

@@ -999,3 +1008,3 @@

channel.subscribeAttempts = 0;
self._trySubscribe(socket, channel);
self._trySubscribe(channel);
}

@@ -1002,0 +1011,0 @@ })(this._channels[i]);

{
"name": "socketcluster-client",
"description": "Client side of SocketCluster",
"version": "1.3.6",
"version": "1.3.7",
"homepage": "http://socketcluster.io",

@@ -6,0 +6,0 @@ "contributors": [

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc