Skip to content

Commit

Permalink
fixed issue #29
Browse files Browse the repository at this point in the history
  • Loading branch information
impronunciable committed May 9, 2013
1 parent 426d412 commit 21ebb9e
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions lib/tuiter.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,25 +143,20 @@ Tuiter.prototype.handleStream = function(req, endpoint, params, callback) {
var args = stream.args = arguments;
stream.emitAPIEvents();
stream.autoReconnect();

req.pipe(stream);
req.req.on('response', function(res){
res.setEncoding('utf8');
});


req.pipe(stream);
callback(stream);

stream.on('end', function(){
if(stream.res) stream.res.removeAllListeners('end');
stream.end();
req = stream = null;
});

stream.on('reconnect', function(new_args){
params = new_args || params;
if(stream.res) stream.res.removeAllListeners('end');
req = stream = null;
APIRequest.call(self, endpoint, params, callback);
stream.emit('end');
preProcess(params);
APIRequest.call(self, endpoint, params, callback);
});
};

Expand Down

0 comments on commit 21ebb9e

Please sign in to comment.