Class: Firehose::Rack::Consumer::HttpLongPoll::DefaultHandler

Inherits:
Handler
  • Object
show all
Defined in:
lib/firehose/rack/consumer/http_long_poll.rb

Instance Method Summary collapse

Methods inherited from Handler

#call, #initialize

Methods included from Helpers

#response

Constructor Details

This class inherits a constructor from Firehose::Rack::Consumer::HttpLongPoll::Handler

Instance Method Details

#handle_request(request, env) ⇒ Object



123
124
125
126
127
128
129
130
131
132
# File 'lib/firehose/rack/consumer/http_long_poll.rb', line 123

def handle_request(request, env)
  # Get the Last Message Sequence from the query string.
  # Ideally we'd use an HTTP header, but android devices don't let us
  # set any HTTP headers for CORS requests.
  last_sequence = request.params['last_message_sequence'].to_i
  channel       = request.path

  log_request   channel, last_sequence, env
  respond_async channel, last_sequence, env
end

#log_request(path, last_sequence, env) ⇒ Object



119
120
121
# File 'lib/firehose/rack/consumer/http_long_poll.rb', line 119

def log_request(path, last_sequence, env)
  Firehose.logger.debug "HTTP GET with last_sequence #{last_sequence} for path #{path} with query #{env["QUERY_STRING"].inspect}"
end

#wrap_frame(channel, message) ⇒ Object



115
116
117
# File 'lib/firehose/rack/consumer/http_long_poll.rb', line 115

def wrap_frame(channel, message)
  JSON.generate :message => message.payload, :last_sequence => message.sequence
end