From 1620d3b60df1f9635169308405f2d1e4cf13464f Mon Sep 17 00:00:00 2001 From: Tim Cameron Ryan Date: Thu, 24 Apr 2014 19:48:00 -0400 Subject: [PATCH] Release 0.2.8. Adds "close" event to sockets. --- lib/index.js | 2 ++ package.json | 2 +- test/close.js | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 86f24b6..73c9948 100644 --- a/lib/index.js +++ b/lib/index.js @@ -202,6 +202,8 @@ Socket.prototype.close = function () { this._stopPollSend(); this._stopPollReceive(); + this.emit('close'); + return this.closed_status; } diff --git a/package.json b/package.json index 6df8d49..3fb41d0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nanomsg", - "version": "0.2.7", + "version": "0.2.8", "description": "Node bindings for nanomsg", "main": "lib/index.js", "dependencies": { diff --git a/test/close.js b/test/close.js index 3a3720d..0e8a002 100644 --- a/test/close.js +++ b/test/close.js @@ -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();