Class: Firehose::Rack::Consumer::WebSocket

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

Overview

It may be more memory efficient if we used the same instance of this class (or if we even just used a lambda) for every connection.

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



102
103
104
105
106
107
108
109
110
111
# File 'lib/firehose/rack/consumer.rb', line 102

def call(env)
  req   = ::Rack::Request.new env
  @ws   = Faye::WebSocket.new env
  @path = req.path
  @ws.onopen    = method :handle_open
  @ws.onclose   = method :handle_close
  @ws.onerror   = method :handle_error
  @ws.onmessage = method :handle_message
  return @ws.rack_response
end