Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed data events not being captured #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 11 additions & 8 deletions lib/main.js
Expand Up @@ -7,6 +7,7 @@ var request = require('request'),
var end = '\r\n';

function createTweetStream (options) {
var req;
var buffer = '';
var stopped = false;

Expand All @@ -27,7 +28,7 @@ function createTweetStream (options) {
options.uri = 'http://chirpstream.twitter.com/2b/user.json';
}
}

if (typeof options.uri === "string") {
options.query = options.query ? options.query : { count:options.count, follow: options.follow
, track : options.track ? options.track.join(',') : undefined
Expand Down Expand Up @@ -86,20 +87,22 @@ function createTweetStream (options) {
options.client.end();
})

options.responseBodyStream = stream;
options.method = 'POST';
options.headers = {'content-type':'application/json'};

stream.readable = true;
stream.writable = true;
var start = function () {
request(options, function (error, response) {
req = request(options, function (error, response, body) {
if (!stopped) {
delete options.client;
setTimeout(start, options.delay)
}
})
});
req.pipe(stream);
}
start();

start();

stream.rest = function (opts, callback) {
var uri = url.parse(opts.uri);
var method = opts.method;
Expand All @@ -118,8 +121,8 @@ function createTweetStream (options) {
return stream.rest(opts, callback);
}
}

return stream;
}

exports.createTweetStream = createTweetStream;
exports.createTweetStream = createTweetStream;