0.0
No commit activity in last 3 years
No release in over 3 years
Bayeux (COMET or long-polling) protocol server as a Sinatra application. Light weight and high scalability are achieved by using the asynchronous Rack extensions added to Thin by async_sinatra.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 1.4.6
>= 1.2
 Project Readme

bayeux.rack¶ ↑

Bayeux (COMET or long-polling) protocol server as a Sinatra application. Light weight and high scalability are achieved by using the asynchronous Rack extensions added to Thin by async_sinatra.

Because it uses async_sinatra, which uses EventMachine, it won’t work in Passenger. Sorry about that, but Apache doesn’t really like long-polling anyhow. Use Thin.

You can see a video presentation of this code here: www.youtube.com/watch?v=Bhj9QOfNd4c

Usage¶ ↑

See github.com/cjheath/jquery.comet for an example of usage and for a COMET client in Javascript.

class MyServer < Bayeux
  configure do
    # The default :public is inside the Bayeux gem
    set :public, File.dirname(__FILE__)
  end

  def deliver message
    case channel_name = message['channel']
    when '/my/interesting/channel'

data = message if data == ‘ping’ publish :channel => channel_name, :data => ‘pong’ else super end

else

super

    end
  end
end

Installing¶ ↑

gem install bayeux-rack

License¶ ↑

The MIT license.

Developing¶ ↑

Fork on github github.com/cjheath/bayeux-rack or just clone to play:

git clone git://github.com/cjheath/bayeux-rack.git

Patches welcome! Fork and send a pull request. Please follow coding conventions already in use. Please use jslint if you can. There are currently no warnings, please keep it that way.

Status¶ ↑

Current release has a happy path (working ok). Significant drawbacks to be fixed are:

  • Server-side timeout of long-polls to avoid possible loss of sent messages

  • Detecting multiple connections (tabs?) from the same browser, to fall back to callback polling.