Class: Rack::WebSocket::Handler::Base
- Inherits:
-
Object
- Object
- Rack::WebSocket::Handler::Base
- Defined in:
- lib/rack/websocket/handler/base.rb,
lib/rack/websocket/handler/base/connection.rb
Defined Under Namespace
Classes: Connection
Instance Method Summary collapse
-
#call(env) ⇒ Object
Implemented in subclass.
-
#close_websocket ⇒ Object
Implemented in subclass.
-
#initialize(parent, options = {}) ⇒ Base
constructor
Set application as parent and forward options.
-
#on_close ⇒ Object
Fired when a message from a client is received.
-
#on_error(error) ⇒ Object
Fired when a client is disconnected.
-
#on_message(msg) ⇒ Object
Fired when a client is connected.
- #on_open ⇒ Object
-
#send_data(data) ⇒ Object
Implemented in subclass.
- #set_env_instance_variable ⇒ Object
- #set_parent_instance_variables ⇒ Object
- #set_session_instance_variable ⇒ Object
Constructor Details
#initialize(parent, options = {}) ⇒ Base
Set application as parent and forward options
29 30 31 32 |
# File 'lib/rack/websocket/handler/base.rb', line 29 def initialize(parent, = {}) @parent = parent @options = [:backend] || {} end |
Instance Method Details
#call(env) ⇒ Object
Implemented in subclass
49 50 51 |
# File 'lib/rack/websocket/handler/base.rb', line 49 def call(env) raise 'Not implemented' end |
#close_websocket ⇒ Object
Implemented in subclass
59 60 61 |
# File 'lib/rack/websocket/handler/base.rb', line 59 def close_websocket raise 'Not implemented' end |
#on_close ⇒ Object
Fired when a message from a client is received.
18 19 20 21 |
# File 'lib/rack/websocket/handler/base.rb', line 18 def on_close set_parent_instance_variables @parent.on_close(@env) end |
#on_error(error) ⇒ Object
Fired when a client is disconnected.
23 24 25 26 |
# File 'lib/rack/websocket/handler/base.rb', line 23 def on_error(error) set_parent_instance_variables @parent.on_error(@env, error) end |
#on_message(msg) ⇒ Object
Fired when a client is connected.
13 14 15 16 |
# File 'lib/rack/websocket/handler/base.rb', line 13 def (msg) set_parent_instance_variables @parent.(@env, msg) end |
#on_open ⇒ Object
8 9 10 11 |
# File 'lib/rack/websocket/handler/base.rb', line 8 def on_open set_parent_instance_variables @parent.on_open(@env) end |
#send_data(data) ⇒ Object
Implemented in subclass
54 55 56 |
# File 'lib/rack/websocket/handler/base.rb', line 54 def send_data(data) raise 'Not implemented' end |
#set_env_instance_variable ⇒ Object
39 40 41 |
# File 'lib/rack/websocket/handler/base.rb', line 39 def set_env_instance_variable @parent.instance_variable_set("@env", @env) end |
#set_parent_instance_variables ⇒ Object
34 35 36 37 |
# File 'lib/rack/websocket/handler/base.rb', line 34 def set_parent_instance_variables set_env_instance_variable set_session_instance_variable end |
#set_session_instance_variable ⇒ Object
43 44 45 46 |
# File 'lib/rack/websocket/handler/base.rb', line 43 def set_session_instance_variable session = Noodles.use_memached_as_session_storage ? Noodles::MemcachedSession.new(@env) : @env['rack.session'] @parent.instance_variable_set("@session", session) end |