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 = 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

#tokenObject

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