views:

40

answers:

2

Is there any gem for ruby (i want to use it in a rails app) that does somethink like Twitter Stream API. Keep the http conection opened and send information in real time based in a query or events.

+1  A: 

You need:

  • a server that speaks HTTP in order to be able to understand queries and respond valid HTTP to the client
  • an asynchronous system that will push updates in the connection established with the client when there's new data available.

Then thin is an options you might consider, it has a builtin http parser for the first requirement, and eventmachine for the second.

Have a look at this example (run it with thin --rackup async_tailer.ru start). It is tailing asynchronously the /var/log/syslog through a open http connection. You can adapt this example to send data from other asynchronous sources from which you would like data to come.

hellvinz
+1  A: 

I think twitter-stream should do what you want.

floehopper
this is a client for the twitter stream api, i think the questionner is asking how to implement a similar service.
hellvinz