Skip to content

Commit

Permalink
Release 0.2.8. Adds "close" event to sockets.
Browse files Browse the repository at this point in the history
  • Loading branch information
tcr committed Apr 24, 2014
1 parent 2fac41a commit 1620d3b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ Socket.prototype.close = function () {
this._stopPollSend();
this._stopPollReceive();

this.emit('close');

return this.closed_status;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nanomsg",
"version": "0.2.7",
"version": "0.2.8",
"description": "Node bindings for nanomsg",
"main": "lib/index.js",
"dependencies": {
Expand Down
6 changes: 5 additions & 1 deletion test/close.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ test('throw exception when closing invalid socket', function (t) {
// We can test a double close on the same socket tho.
// Currently this is rigged so that the second (and any subsequent)
// close returns the same value as the first.
t.plan(1);
t.plan(2);

var sock = nano.socket('pub');

sock.on('close', function (){
t.ok(true, 'socket emitted close event');
})

var rc = sock.close();
var rc2 = sock.close();

Expand Down

0 comments on commit 1620d3b

Please sign in to comment.