Class: Cramp::Action
- Includes:
- KeepConnectionAlive, PeriodicTimer
- Defined in:
- lib/cramp/action.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(env) ⇒ Action
constructor
A new instance of Action.
Methods included from KeepConnectionAlive
Methods inherited from Abstract
Methods included from Callbacks
#before_start, #callback_wrapper, #on_finish, #on_start
Constructor Details
#initialize(env) ⇒ Action
Returns a new instance of Action.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cramp/action.rb', line 6 def initialize(env) super case when Faye::EventSource.eventsource?(env) # request has Accept: text/event-stream # faye server adapter intercepts headers - need to send them in send_initial_response or use faye's implementation @eventsource_detected = true unless transport == :sse err = "WARNING: Cramp got request with EventSource header on action with transport #{transport} (not sse)! Response may not contain valid http headers!" Cramp.logger ? Cramp.logger.error(err) : $stderr.puts(err) end when Faye::WebSocket.websocket?(env) @web_socket = Faye::WebSocket.new(env) @web_socket. = lambda do |event| = event.data _invoke_data_callbacks() if .is_a?(String) end end end |