Emit "close" for ws transport
This commit is contained in:
parent
cb917c6bda
commit
5f96a5d893
|
@ -194,6 +194,12 @@ WsTransport.prototype.listen = function(options, callback) {
|
|||
server.on("error", function(err) {
|
||||
self.emit("error", err);
|
||||
});
|
||||
|
||||
// `ws` doesn't emit "close" event by default.
|
||||
server._server.on("close", function() {
|
||||
self.emit("close");
|
||||
delete self._server;
|
||||
});
|
||||
};
|
||||
|
||||
WsTransport.prototype.send = function() {
|
||||
|
@ -221,10 +227,7 @@ WsTransport.prototype.close = function() {
|
|||
if (this._client) {
|
||||
this._client.close();
|
||||
} else if (this._server) {
|
||||
// `ws` server terminates immediately without any events.
|
||||
this._server.close();
|
||||
this.emit("close");
|
||||
delete this._server;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user