Skip to content

Commit

Permalink
make sure server gets close
Browse files Browse the repository at this point in the history
  • Loading branch information
Narciso Guillen committed Jun 24, 2014
1 parent 328a9df commit fbdb94d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/index.js
Expand Up @@ -211,6 +211,9 @@ Server.prototype.attach = function(srv, opts){
res.end();
});
srv.listen(port);

// Export http server
this.httpServer = srv;
}

// set engine.io path to `/socket.io`
Expand Down Expand Up @@ -328,6 +331,24 @@ Server.prototype.of = function(name, fn){
return this.nsps[name];
};

/**
* Closes server connection
*
* @api public
*/

Server.prototype.close = function(){
this.nsps['/'].sockets.forEach(function(socket){
socket.onclose();
});

this.engine.close();

if(this.httpServer){
this.httpServer.close();
}
};

/**
* Expose main namespace (/).
*/
Expand Down

0 comments on commit fbdb94d

Please sign in to comment.