Skip to content

Commit

Permalink
client: add 'close' event
Browse files Browse the repository at this point in the history
  • Loading branch information
mscdex committed Jul 14, 2014
1 parent 9e3035c commit 63fe5ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ Client events

* **error**(< _Error_ >err) - Emitted when a parser, socket (during handshaking/negotiation), or DNS (if `localDNS` and `strictLocalDNS` are `true`) error occurs.

* **close**(< _boolean_ >had_error) - Emitted when the client is closed (due to error and/or socket closed).


Client methods
--------------
Expand Down
3 changes: 3 additions & 0 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ function Client(options) {
self._hadError = true;
self.emit('error', err);
}
}).on('close', function(had_err) {
self.emit('close', self._hadError || had_err);
});

this._parser = undefined;
Expand Down Expand Up @@ -186,6 +188,7 @@ Client.prototype.connect = function(options, cb) {
if (err && self._strictLocalDNS) {
self._hadError = true;
self.emit('error', err);
self.emit('close', true);
return;
}
if (addr)
Expand Down

0 comments on commit 63fe5ce

Please sign in to comment.