Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sinatra server push?

Tags:

ruby

sinatra

What is the best way to push data from a server written in Sinatra to a client? Think similarly to a chat room, but without Ajax polling every 2500ms.

I know of Juggernaut in Rails, but was curious about Sinatra.

like image 672
sullivan.t Avatar asked Jul 08 '09 16:07

sullivan.t


People also ask

What is a Sinatra server?

Sinatra is a lightweight domain-specific programming language and web application library that is used for writing web applications. It provides a faster and simpler alternative to Ruby frameworks such as Ruby on Rails.

What is Sinatra :: Base?

Sinatra::Base is the Sinatra without delegation. Consider the following code with delegation: # app.rb require 'sinatra' get '/' do render :template end.


1 Answers

A little googling turned up this blog post by Marc-André Cournoyer, which discusses the asynchronous response feature of the Thin web server and includes a link to an async-sinatra library to do just this. You could also take a look at orbited-ruby, a Ruby implementation of the Orbited Comet server. Both of these appear to be pretty new and untested, so you might have to do a little hacking yourselves to get things working correctly for your application.

like image 189
Greg Campbell Avatar answered Oct 15 '22 14:10

Greg Campbell