2012-01-07 39 views
0

嗨,我有以下代码:“网”拒绝发出“关闭”事件的NodeJS

this.stop = function() { 
    this.server.close(); 
    var thisServer = this; 
    this.server.on('close',function() { 
     thisServer.emit('stop');   
    });  
}; 

使用服务器和调用停止功能后,服务器拒绝 发出“关闭”事件

this.server.on('close',function() { 
     thisServer.emit('stop');   
    }); 

我做错了什么?

回答

1
this.server.on('close',function() { 
    thisServer.emit('stop');   
});  
this.server.close(); 
var thisServer = this; 

在调用close之前绑定关闭事件。

或者尝试this.server.destroy();