Class: Rack::WebSocket::Application
- Inherits:
-
Object
- Object
- Rack::WebSocket::Application
- Defined in:
- lib/rack/websocket/application.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{}
Class Attribute Summary collapse
-
.websocket_handler ⇒ Object
Returns the value of attribute websocket_handler.
Instance Method Summary collapse
-
#_call(env) ⇒ Object
Forward call to duplicated handler.
-
#call(env) ⇒ Object
Detect handler and duplicate it’s instance.
-
#initialize(options = {}) ⇒ Application
constructor
Initializer.
-
#method_missing(sym, *args, &block) ⇒ Object
Forward all missing methods to handler.
- #on_close(env) ⇒ Object
- #on_error(env, error) ⇒ Object
- #on_message(env, msg) ⇒ Object
-
#on_open(env) ⇒ Object
Standard WebSocket calls.
Constructor Details
#initialize(options = {}) ⇒ Application
Initializer
18 19 20 |
# File 'lib/rack/websocket/application.rb', line 18 def initialize( = {}) @options = DEFAULT_OPTIONS.merge() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
Forward all missing methods to handler
34 35 36 37 38 39 40 |
# File 'lib/rack/websocket/application.rb', line 34 def method_missing(sym, *args, &block) if websocket_handler && websocket_handler.respond_to?(sym) websocket_handler.send sym, *args, &block else super end end |
Class Attribute Details
.websocket_handler ⇒ Object
Returns the value of attribute websocket_handler.
8 9 10 |
# File 'lib/rack/websocket/application.rb', line 8 def websocket_handler @websocket_handler end |
Instance Method Details
#_call(env) ⇒ Object
Forward call to duplicated handler
29 30 31 |
# File 'lib/rack/websocket/application.rb', line 29 def _call(env) websocket_handler.call(env) end |
#call(env) ⇒ Object
Detect handler and duplicate it’s instance
23 24 25 26 |
# File 'lib/rack/websocket/application.rb', line 23 def call(env) detect_handler(env) dup._call(env) end |
#on_close(env) ⇒ Object
14 |
# File 'lib/rack/websocket/application.rb', line 14 def on_close(env); end |
#on_error(env, error) ⇒ Object
15 |
# File 'lib/rack/websocket/application.rb', line 15 def on_error(env, error); end |
#on_message(env, msg) ⇒ Object
13 |
# File 'lib/rack/websocket/application.rb', line 13 def (env, msg); end |
#on_open(env) ⇒ Object
Standard WebSocket calls
12 |
# File 'lib/rack/websocket/application.rb', line 12 def on_open(env); end |