Skip to content

Commit 1620d3b

Browse files
committed
Release 0.2.8. Adds "close" event to sockets.
1 parent 2fac41a commit 1620d3b

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

lib/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ Socket.prototype.close = function () {
202202
this._stopPollSend();
203203
this._stopPollReceive();
204204

205+
this.emit('close');
206+
205207
return this.closed_status;
206208
}
207209

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nanomsg",
3-
"version": "0.2.7",
3+
"version": "0.2.8",
44
"description": "Node bindings for nanomsg",
55
"main": "lib/index.js",
66
"dependencies": {

test/close.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@ test('throw exception when closing invalid socket', function (t) {
2121
// We can test a double close on the same socket tho.
2222
// Currently this is rigged so that the second (and any subsequent)
2323
// close returns the same value as the first.
24-
t.plan(1);
24+
t.plan(2);
2525

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

28+
sock.on('close', function (){
29+
t.ok(true, 'socket emitted close event');
30+
})
31+
2832
var rc = sock.close();
2933
var rc2 = sock.close();
3034

0 commit comments

Comments
 (0)