Sha256: ace97548fa1bd6f9e5c5faae6592704b1a2f0ef2f22437724279a13c9d773cc8

Contents?: true

Size: 784 Bytes

Versions: 2

Compression:

Stored size: 784 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 :start
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sinatra-rocketio-0.0.9 lib/sinatra-rocketio/application.rb
sinatra-rocketio-0.0.8 lib/sinatra-rocketio/application.rb