Reputation: 1453
hi I have the following code:
this.stop = function() {
this.server.close();
var thisServer = this;
this.server.on('close',function() {
thisServer.emit('stop');
});
};
after using the server and calling the stop function, the server refuses to emit 'close' event and
this.server.on('close',function() {
thisServer.emit('stop');
});
am I doing something wrong?
Upvotes: 0
Views: 316
Reputation: 169391
this.server.on('close',function() {
thisServer.emit('stop');
});
this.server.close();
var thisServer = this;
Bind the close event before you invoke close.
Alternatively try this.server.destroy();
Upvotes: 1