I'm using node and socket io to stream tweets in the browser using the Twitter Streaming API. I've tried to slow down the speed of the stream by using setTimeout/setInterval on the stream event, but this only ever seems to delay the start of the stream, rather than space out the tweet stream consistently. Does anybody know how to solve this issue?
Here's my server side code:
io.sockets.on("connection", function(socket){
console.log('connected');
var US = ['-125.0011', '24.9493', '-66.9326', '49.5904'];
var stream = client.stream('statuses/filter', {locations: US});
stream.on('tweet', function(tweet){
if(tweet.coordinates && tweet.coordinates != null){
io.sockets.emit('stream', tweet);
}
});
});
And on the client side it's just the following script:
$(document).ready(function(){
var socket = io.connect();
socket.on('stream', function(tweet){
$('#tw').prepend('<h4>' + tweet.text + '</h4>' + '</br>');
});
});