Class: Firehose::Rack::Consumer
- Inherits:
-
Object
- Object
- Firehose::Rack::Consumer
- Defined in:
- lib/firehose/rack/consumer.rb,
lib/firehose/rack/consumer/web_socket.rb,
lib/firehose/rack/consumer/http_long_poll.rb
Overview
Handles a subscription request over HTTP or WebSockets depeding on its abilities and binds that to the Firehose::Server::Subscription class, which is bound to a channel that gets published to.
Defined Under Namespace
Classes: HttpLongPoll, WebSocket
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#http_long_poll ⇒ Object
Memoized instance of http long poll handler that can be configured from the rack app.
-
#initialize {|_self| ... } ⇒ Consumer
constructor
Let the client configure the consumer on initialization.
-
#websocket ⇒ Object
Memoized instance of web socket that can be configured from the rack app.
Constructor Details
#initialize {|_self| ... } ⇒ Consumer
Let the client configure the consumer on initialization.
14 15 16 |
# File 'lib/firehose/rack/consumer.rb', line 14 def initialize yield self if block_given? end |
Instance Method Details
#call(env) ⇒ Object
18 19 20 |
# File 'lib/firehose/rack/consumer.rb', line 18 def call(env) websocket_request?(env) ? websocket.call(env) : http_long_poll.call(env) end |
#http_long_poll ⇒ Object
Memoized instance of http long poll handler that can be configured from the rack app.
28 29 30 |
# File 'lib/firehose/rack/consumer.rb', line 28 def http_long_poll @http_long_poll ||= HttpLongPoll.new end |