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 client is disconnected.
-
#on_error(error) ⇒ Object
Fired when error occurs.
-
#on_message(msg) ⇒ Object
Fired when a message from a client is received.
-
#on_open ⇒ Object
Fired when a client is connected.
-
#send_data(data) ⇒ Object
Implemented in subclass.
Constructor Details
#initialize(parent, options = {}) ⇒ Base
Set application as parent and forward options
14 15 16 17 |
# File 'lib/rack/websocket/handler/base.rb', line 14 def initialize(parent, = {}) @parent = parent @options = [:backend] || {} end |
Instance Method Details
#call(env) ⇒ Object
Implemented in subclass
20 21 22 |
# File 'lib/rack/websocket/handler/base.rb', line 20 def call(env) raise 'Not implemented' end |
#close_websocket ⇒ Object
Implemented in subclass
30 31 32 |
# File 'lib/rack/websocket/handler/base.rb', line 30 def close_websocket raise 'Not implemented' end |
#on_close ⇒ Object
Fired when a client is disconnected.
10 |
# File 'lib/rack/websocket/handler/base.rb', line 10 def on_close; @parent.on_close(@env); end |
#on_error(error) ⇒ Object
Fired when error occurs.
11 |
# File 'lib/rack/websocket/handler/base.rb', line 11 def on_error(error); @parent.on_error(@env, error); end |
#on_message(msg) ⇒ Object
Fired when a message from a client is received.
9 |
# File 'lib/rack/websocket/handler/base.rb', line 9 def (msg); @parent.(@env, msg); end |
#on_open ⇒ Object
Fired when a client is connected.
8 |
# File 'lib/rack/websocket/handler/base.rb', line 8 def on_open; @parent.on_open(@env); end |
#send_data(data) ⇒ Object
Implemented in subclass
25 26 27 |
# File 'lib/rack/websocket/handler/base.rb', line 25 def send_data(data) raise 'Not implemented' end |