Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #78 from james-huston/master

Added callback to Socket.close to mimic Socket.listen.
  • Loading branch information...
commit f6fe0247c737dbd1e20c7dc1c48021a4d34f14e2 2 parents 6f6f992 + 66379ee
@tj authored
Showing with 22 additions and 2 deletions.
  1. +2 −2 lib/sockets/sock.js
  2. +20 −0 test/test.socket.close.js
View
4 lib/sockets/sock.js
@@ -149,14 +149,14 @@ Socket.prototype.closeSockets = function(){
* @api public
*/
-Socket.prototype.close = function(){
+Socket.prototype.close = function(fn){
debug('closing');
this.closing = true;
this.closeSockets();
if (this.server) {
debug('closing server');
this.server.on('close', this.emit.bind(this, 'close'));
- this.server.close();
+ this.server.close(fn);
}
};
View
20 test/test.socket.close.js
@@ -0,0 +1,20 @@
+
+var axon = require('..')
+ , assert = require('better-assert');
+
+var pull = axon.socket('pull');
+
+var closed = false;
+var callbackClose = function() {
+ closed = true;
+}
+
+pull.bind(4444, function() {
+ pull.close(callbackClose);
+});
+
+pull.on('close', function() {
+ setTimeout(function() {
+ assert(closed === true);
+ }, 100);
+});
Please sign in to comment.
Something went wrong with that request. Please try again.