devicestack
Advanced tools
Comparing version 1.9.4 to 1.9.5
@@ -76,8 +76,15 @@ var EventEmitter2 = require('eventemitter2').EventEmitter2, | ||
if (self.onConnecting) { | ||
self.onConnecting(function() { | ||
if (self.log) self.log('connect connection with id ' + self.id); | ||
self.device.emit('connect', self.device); | ||
self.set('state', 'connect'); | ||
self.emit('connect', self); | ||
if (callback) callback(null, self); | ||
self.onConnecting(function(err) { | ||
if (err) { | ||
if (self.log) self.log('could not connect connection with id ' + self.id); | ||
self.close(function() { | ||
if (callback) callback(err, self); | ||
}); | ||
} else { | ||
if (self.log) self.log('connect connection with id ' + self.id); | ||
self.device.emit('connect', self.device); | ||
self.set('state', 'connect'); | ||
self.emit('connect', self); | ||
if (callback) callback(null, self); | ||
} | ||
}); | ||
@@ -186,3 +193,3 @@ } else { | ||
Connection.prototype.close = function(callback) { | ||
if (this.get('state') !== 'connect') { | ||
if (this.get('state') !== 'connect' && this.get('state') !== 'connecting') { | ||
if (callback) callback(new Error('Connection is already "' + this.get('state') + '"!')); | ||
@@ -189,0 +196,0 @@ return; |
@@ -318,9 +318,12 @@ var util = require('util'), | ||
if (err) { | ||
if (self.log) self.log('Error while calling connect: ' + JSON.stringify(err)); | ||
if (!err.name) { | ||
err = new Error(err); | ||
} | ||
if (self.log) self.log('Error while calling connect: ' + err.name + (err.message ? ': ' + err.message : '')); | ||
if (callback) { | ||
if (!err.name) { | ||
err = new Error(err); | ||
} | ||
callback(err, connection); | ||
} | ||
self.emit('disconnect', connection); | ||
self.emit('connectionStateChanged', { state: 'disconnect', connection: connection, device: device }); | ||
return; | ||
@@ -327,0 +330,0 @@ } |
{ | ||
"name": "devicestack", | ||
"version": "1.9.4", | ||
"version": "1.9.5", | ||
"description": "This module helps you to represent a device and its protocol.", | ||
@@ -30,6 +30,8 @@ "private": false, | ||
"mocha": ">=1.0.1", | ||
"expect.js": ">=0.1.2" | ||
"expect.js": ">=0.1.2", | ||
"istanbul": ">=0.1.44" | ||
}, | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "mocha", | ||
"cov": "istanbul cover _mocha" | ||
}, | ||
@@ -36,0 +38,0 @@ "repository": { |
@@ -0,1 +1,4 @@ | ||
## v1.9.5 | ||
- handle errors while connecting | ||
## v1.9.4 | ||
@@ -2,0 +5,0 @@ - do not call callback twice if error is throwing on consumer callback |
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
117188
2443
3