radar_client
Advanced tools
Comparing version 0.16.1 to 0.16.2
@@ -175,2 +175,6 @@ var RadarClient = | ||
Client.prototype.attachStateMachineErrorHandler = function (errorHandler) { | ||
this.manager.attachErrorHandler(errorHandler) | ||
} | ||
Client.prototype.currentUserId = function () { | ||
@@ -403,2 +407,10 @@ return this._configuration && this._configuration.userId | ||
socket.once('open', function () { | ||
if (socket !== self._socket) { | ||
socket.removeAllListeners('message') | ||
socket.removeAllListeners('open') | ||
socket.removeAllListeners('close') | ||
socket.close() | ||
return | ||
} | ||
self.logger().debug('socket open', socket.id) | ||
@@ -411,4 +423,2 @@ manager.established() | ||
socket.removeAllListeners('message') | ||
self._socket = null | ||
// Patch for polling-xhr continuing to poll after socket close (HTTP:POST | ||
@@ -422,4 +432,7 @@ // failure). socket.transport is in error but not closed, so if a subsequent | ||
if (!manager.is('closed')) { | ||
manager.disconnect() | ||
if (socket === self._socket) { | ||
self._socket = null | ||
if (!manager.is('closed')) { | ||
manager.disconnect() | ||
} | ||
} | ||
@@ -429,2 +442,9 @@ }) | ||
socket.on('message', function (message) { | ||
if (socket !== self._socket) { | ||
socket.removeAllListeners('message') | ||
socket.removeAllListeners('open') | ||
socket.removeAllListeners('close') | ||
socket.close() | ||
return | ||
} | ||
self._messageReceived(message) | ||
@@ -440,5 +460,9 @@ }) | ||
manager.on('activate', function () { | ||
self._identitySet() | ||
self._restore() | ||
self.emit('ready') | ||
if (self._socket === null) { | ||
manager.disconnect() | ||
} else { | ||
self._identitySet() | ||
self._restore() | ||
self.emit('ready') | ||
} | ||
}) | ||
@@ -741,3 +765,7 @@ | ||
if (err) { | ||
throw err | ||
if (this.errorHandler) { | ||
this.errorHandler(name, from, to, args, type, message, err) | ||
} else { | ||
throw err | ||
} | ||
} | ||
@@ -861,2 +889,10 @@ }, | ||
machine.attachErrorHandler = function (errorHandler) { | ||
if (typeof errorHandler === 'function') { | ||
this.errorHandler = errorHandler | ||
} else { | ||
log.warn('errorHandler must be a function') | ||
} | ||
} | ||
return machine | ||
@@ -1107,3 +1143,3 @@ } | ||
function getClientVersion () { return '0.16.1' } | ||
function getClientVersion () { return '0.16.2' } | ||
@@ -1110,0 +1146,0 @@ module.exports = getClientVersion |
// Auto-generated file, overwritten by scripts/add_package_version.js | ||
function getClientVersion () { return '0.16.1' } | ||
function getClientVersion () { return '0.16.2' } | ||
module.exports = getClientVersion |
@@ -112,2 +112,6 @@ /* globals setImmediate */ | ||
Client.prototype.attachStateMachineErrorHandler = function (errorHandler) { | ||
this.manager.attachErrorHandler(errorHandler) | ||
} | ||
Client.prototype.currentUserId = function () { | ||
@@ -340,2 +344,10 @@ return this._configuration && this._configuration.userId | ||
socket.once('open', function () { | ||
if (socket !== self._socket) { | ||
socket.removeAllListeners('message') | ||
socket.removeAllListeners('open') | ||
socket.removeAllListeners('close') | ||
socket.close() | ||
return | ||
} | ||
self.logger().debug('socket open', socket.id) | ||
@@ -348,4 +360,2 @@ manager.established() | ||
socket.removeAllListeners('message') | ||
self._socket = null | ||
// Patch for polling-xhr continuing to poll after socket close (HTTP:POST | ||
@@ -359,4 +369,7 @@ // failure). socket.transport is in error but not closed, so if a subsequent | ||
if (!manager.is('closed')) { | ||
manager.disconnect() | ||
if (socket === self._socket) { | ||
self._socket = null | ||
if (!manager.is('closed')) { | ||
manager.disconnect() | ||
} | ||
} | ||
@@ -366,2 +379,9 @@ }) | ||
socket.on('message', function (message) { | ||
if (socket !== self._socket) { | ||
socket.removeAllListeners('message') | ||
socket.removeAllListeners('open') | ||
socket.removeAllListeners('close') | ||
socket.close() | ||
return | ||
} | ||
self._messageReceived(message) | ||
@@ -377,5 +397,9 @@ }) | ||
manager.on('activate', function () { | ||
self._identitySet() | ||
self._restore() | ||
self.emit('ready') | ||
if (self._socket === null) { | ||
manager.disconnect() | ||
} else { | ||
self._identitySet() | ||
self._restore() | ||
self.emit('ready') | ||
} | ||
}) | ||
@@ -382,0 +406,0 @@ |
@@ -13,3 +13,7 @@ var log = require('minilog')('radar_state') | ||
if (err) { | ||
throw err | ||
if (this.errorHandler) { | ||
this.errorHandler(name, from, to, args, type, message, err) | ||
} else { | ||
throw err | ||
} | ||
} | ||
@@ -133,2 +137,10 @@ }, | ||
machine.attachErrorHandler = function (errorHandler) { | ||
if (typeof errorHandler === 'function') { | ||
this.errorHandler = errorHandler | ||
} else { | ||
log.warn('errorHandler must be a function') | ||
} | ||
} | ||
return machine | ||
@@ -135,0 +147,0 @@ } |
{ | ||
"name": "radar_client", | ||
"description": "Realtime apps with a high level API based on engine.io", | ||
"version": "0.16.1", | ||
"version": "0.16.2", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "author": "Zendesk, Inc.", |
var assert = require('assert') | ||
var sinon = require('sinon') | ||
var RadarClient = require('../lib/radar_client.js') | ||
@@ -105,2 +106,14 @@ var MockEngine = require('./lib/engine.js')() | ||
'.attachStateMachineErrorHandler': { | ||
'.should attach error handler to the state manager': function () { | ||
var errorHandler = function () {} | ||
var attachErrorHandlerSpy = sinon.spy(client.manager, 'attachErrorHandler') | ||
client.attachStateMachineErrorHandler(errorHandler) | ||
assert.ok(attachErrorHandlerSpy.calledWith(errorHandler)) | ||
attachErrorHandlerSpy.restore() | ||
} | ||
}, | ||
'scopes': { | ||
@@ -655,3 +668,3 @@ '.message should return a scope with the appropriate prefix': function () { | ||
var response = new Response(message) // eslint-disable-line | ||
var response = new Response(message) // eslint-disable-line | ||
assert.deepEqual(client._channelSyncTimes, {}) | ||
@@ -663,3 +676,3 @@ }, | ||
var response = new Response(message) // eslint-disable-line | ||
var response = new Response(message) // eslint-disable-line | ||
assert.deepEqual(client._channelSyncTimes, {}) | ||
@@ -666,0 +679,0 @@ }, |
@@ -161,2 +161,33 @@ var assert = require('assert') | ||
assert(!machine._guard) | ||
}, | ||
'should be able to attach a custom errorHandler': function () { | ||
var handler = function () {} | ||
machine.attachErrorHandler(handler) | ||
assert.equal(machine.errorHandler, handler) | ||
}, | ||
'should be able to override the custom errorHandler': function () { | ||
var handler1 = function () {} | ||
var handler2 = function () {} | ||
machine.attachErrorHandler(handler1) | ||
machine.attachErrorHandler(handler2) | ||
assert.equal(machine.errorHandler, handler2) | ||
}, | ||
'should only allow attaching a function as a custom state machine error handler': function () { | ||
assert(!machine.errorHandler) | ||
machine.attachErrorHandler(23) | ||
assert(!machine.errorHandler) | ||
machine.attachErrorHandler({}) | ||
assert(!machine.errorHandler) | ||
machine.attachErrorHandler('error') | ||
assert(!machine.errorHandler) | ||
machine.attachErrorHandler(function () {}) | ||
assert(machine.errorHandler) | ||
} | ||
@@ -163,0 +194,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
132849
3560
5