Class: JPC::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/jpc/handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#tokenObject

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