From 96e4afdb1b7e5ebe74f92107801bc464a33247f4 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Tue, 18 Mar 2014 14:23:05 +0100 Subject: [PATCH] Have Connection also emit 'end' on stream 'close' event Should fix missing connect callback call with node-0.8 (#534) --- lib/connection.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/connection.js b/lib/connection.js index 0c5e96f2..997b0a73 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -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); }