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 = nil, dispatcher = nil) ⇒ Handler
constructor
A new instance of Handler.
- #ping(params = {}) ⇒ Object
- #subscribe(channel) ⇒ Object
- #unsubscribe(channel) ⇒ Object
Constructor Details
#initialize(ws = nil, dispatcher = nil) ⇒ Handler
Returns a new instance of Handler.
4 5 6 7 |
# File 'lib/jpc/handler.rb', line 4 def initialize(ws = nil, dispatcher = nil) @ws = ws @dispatcher = dispatcher end |
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
2 3 4 |
# File 'lib/jpc/handler.rb', line 2 def token @token end |
Instance Method Details
#ping(params = {}) ⇒ Object
9 10 11 |
# File 'lib/jpc/handler.rb', line 9 def ping(params = {}) "pong #{params}" end |
#subscribe(channel) ⇒ Object
13 14 15 |
# File 'lib/jpc/handler.rb', line 13 def subscribe(channel) @dispatcher.subscribe(@ws, channel) end |
#unsubscribe(channel) ⇒ Object
17 18 19 |
# File 'lib/jpc/handler.rb', line 17 def unsubscribe(channel) @dispatcher.unsubscribe(@ws, channel) end |