2012-01-07 16 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を呼び出す前に、closeイベントをバインドします。

またはtry this.server.destroy();