Skip to content

Commit

Permalink
Merge pull request particle-iot#15 from AntonPuko/fixSocketDisconnect…
Browse files Browse the repository at this point in the history
…Messages

fix socket disconnect messages
  • Loading branch information
jlkalberer authored Jan 3, 2017
2 parents 05919ad + b5c1ab5 commit 7fd7625
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions lib/clients/Device.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,13 @@ var Device = function (_EventEmitter) {
_this._socket.setTimeout(SOCKET_TIMEOUT);

_this._socket.on('error', function (error) {
return _this.disconnect('socket error ' + error.message);
return _this.disconnect('socket error: ' + error.message);
});
_this._socket.on('close', function (error) {
return _this.disconnect('socket close ' + error.message);
_this._socket.on('close', function () {
return _this.disconnect('socket close');
});
_this._socket.on('timeout', function (error) {
return _this.disconnect('socket timeout ' + error.message);
_this._socket.on('timeout', function () {
return _this.disconnect('socket timeout');
});

_context.next = 8;
Expand Down Expand Up @@ -1328,17 +1328,17 @@ var Device = function (_EventEmitter) {
try {
_this._decipherStream.end();
_this._decipherStream = null;
} catch (exception) {
_logger2.default.error('Error cleaning up _decipherStream ', exception);
} catch (error) {
_logger2.default.error('Error cleaning up decipherStream: ' + error);
}
}

if (_this._cipherStream) {
try {
_this._cipherStream.end();
_this._cipherStream = null;
} catch (exception) {
_logger2.default.error('Error cleaning up _cipherStream ', exception);
} catch (error) {
_logger2.default.error('Error cleaning up cipherStream: ' + error);
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/clients/Device.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ class Device extends EventEmitter {

this._socket.on(
'error',
(error: Error): void => this.disconnect(`socket error ${error.message}`),
(error: Error): void => this.disconnect(`socket error: ${error.message}`),
);
this._socket.on(
'close',
(error: Error): void => this.disconnect(`socket close ${error.message}`),
(): void => this.disconnect('socket close'),
);
this._socket.on(
'timeout',
(error: Error): void => this.disconnect(`socket timeout ${error.message}`),
(): void => this.disconnect('socket timeout'),
);

await this.handshake();
Expand Down Expand Up @@ -1237,17 +1237,17 @@ class Device extends EventEmitter {
try {
this._decipherStream.end();
this._decipherStream = null;
} catch (exception) {
logger.error('Error cleaning up _decipherStream ', exception);
} catch (error) {
logger.error(`Error cleaning up decipherStream: ${error}`);
}
}

if (this._cipherStream) {
try {
this._cipherStream.end();
this._cipherStream = null;
} catch (exception) {
logger.error('Error cleaning up _cipherStream ', exception);
} catch (error) {
logger.error(`Error cleaning up cipherStream: ${error}`);
}
}

Expand Down

0 comments on commit 7fd7625

Please sign in to comment.