mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
make sure server gets close
This commit is contained in:
21
lib/index.js
21
lib/index.js
@@ -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`
|
||||
@@ -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 (/).
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user