Class: JPC::Handler
- Inherits:
-
Object
- Object
- JPC::Handler
- Defined in:
- lib/jpc/handler.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(ws, dispatcher) ⇒ Handler
constructor
A new instance of Handler.
- #ping(params = {}) ⇒ Object
- #subscribe(channel) ⇒ Object
- #unsubscribe(channel) ⇒ Object
Constructor Details
#initialize(ws, dispatcher) ⇒ Handler
Returns a new instance of Handler.
5 6 7 8 |
# File 'lib/jpc/handler.rb', line 5 def initialize(ws, dispatcher) @ws = ws @dispatcher = dispatcher end |
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
3 4 5 |
# File 'lib/jpc/handler.rb', line 3 def token @token end |
Instance Method Details
#ping(params = {}) ⇒ Object
10 11 12 |
# File 'lib/jpc/handler.rb', line 10 def ping(params = {}) "pong #{params.inspect}" end |
#subscribe(channel) ⇒ Object
14 15 16 |
# File 'lib/jpc/handler.rb', line 14 def subscribe(channel) @dispatcher.subscribe(@ws, channel) end |
#unsubscribe(channel) ⇒ Object
18 19 20 |
# File 'lib/jpc/handler.rb', line 18 def unsubscribe(channel) @dispatcher.unsubscribe(@ws, channel) end |