Sha256: de90b18f563be964f942785a3ecc0a7a67c6949ca835db6954b4953a763aa383

Contents?: true

Size: 792 Bytes

Versions: 3

Compression:

Stored size: 792 Bytes

Contents

module Sinatra
  module RocketIO

    def self.registered(app)
      app.helpers Sinatra::RocketIO::Helpers
      EM::defer do
        while !EM::reactor_running? do
          sleep 1
        end
        if options[:comet]
          app.register Sinatra::CometIO
        end
        if options[:websocket]
          app.register Sinatra::WebSocketIO
          Sinatra::WebSocketIO.start
        end
        app.get '/rocketio/rocketio.js' do
          content_type 'application/javascript'
          @js ||= ERB.new(Sinatra::RocketIO.javascript).result(binding)
        end
        app.routes["GET"].delete_if{|route|
          "/cometio/cometio.js" =~ route[0] or "/websocketio/websocketio.js" =~ route[0]
        }
        Sinatra::RocketIO.emit :regist_events
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sinatra-rocketio-0.0.7 lib/sinatra-rocketio/application.rb
sinatra-rocketio-0.0.6 lib/sinatra-rocketio/application.rb
sinatra-rocketio-0.0.5 lib/sinatra-rocketio/application.rb