0

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>');
                });             

            });
rekhers
  • 1
  • 3
  • If you could post your code of the streaming function, that will make things easier for us to help you ! – Billy Jan 23 '15 at 10:06
  • Sorry, meant to do that earlier. It's up now! – rekhers Jan 23 '15 at 16:33
  • Looks like pretty much the same question as http://stackoverflow.com/questions/28121580/using-callbacks-with-socket-io which currently has an answer. – jfriend00 Jan 24 '15 at 08:25

0 Answers0