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
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 = [:backend] || {} end |
Instance Method Details
#call(env) ⇒ Object
Implemented in subclass
39 40 41 |
# File 'lib/rack/websocket/handler/base.rb', line 39 def call(env) raise 'Not implemented' end |
#close_websocket ⇒ Object
Implemented in subclass
49 50 51 |
# File 'lib/rack/websocket/handler/base.rb', line 49 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_env_instance_variable @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_env_instance_variable @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_env_instance_variable @parent.(@env, msg) end |
#on_open ⇒ Object
8 9 10 11 |
# File 'lib/rack/websocket/handler/base.rb', line 8 def on_open set_env_instance_variable @parent.on_open(@env) end |
#send_data(data) ⇒ Object
Implemented in subclass
44 45 46 |
# File 'lib/rack/websocket/handler/base.rb', line 44 def send_data(data) raise 'Not implemented' end |
#set_env_instance_variable ⇒ Object
34 35 36 |
# File 'lib/rack/websocket/handler/base.rb', line 34 def set_env_instance_variable @parent.instance_variable_set("@env", @env) end |