Have Connection also emit 'end' on stream 'close' event

Should fix missing connect callback call with node-0.8 (#534)
This commit is contained in:
Sandro Santilli 2014-03-18 14:23:05 +01:00
parent d21b995726
commit 96e4afdb1b

View File

@ -60,6 +60,13 @@ Connection.prototype.connect = function(port, host) {
self.emit('end');
});
this.stream.on('close', function() {
// TODO: avoid emitting 'end' twice ?
// node-0.10 emits both 'end' and 'close'
// for streams closed by the peer
self.emit('end');
});
if(!this.ssl) {
return this.attachListeners(this.stream);
}