Class: WampRails::Command::Subscribe

Inherits:
BaseHandler show all
Defined in:
lib/wamp_rails/commands/subscribe.rb

Instance Attribute Summary collapse

Attributes inherited from BaseCommand

#client, #queue

Instance Method Summary collapse

Methods inherited from BaseHandler

#handler

Methods inherited from BaseCommand

#callback, #session

Constructor Details

#initialize(topic, klass, options, client) ⇒ Subscribe

Returns a new instance of Subscribe.



6
7
8
9
10
11
12
13
14
# File 'lib/wamp_rails/commands/subscribe.rb', line 6

def initialize(topic, klass, options, client)
  super(client, klass)
  self.topic = topic
  self.options = options

  unless self.klass < WampRails::Controller::Subscription
    raise WampRails::Error.new('klass must be a WampRails::Controller::Subscription class')
  end
end

Instance Attribute Details

#klassObject

Returns the value of attribute klass.



4
5
6
# File 'lib/wamp_rails/commands/subscribe.rb', line 4

def klass
  @klass
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/wamp_rails/commands/subscribe.rb', line 4

def options
  @options
end

#topicObject

Returns the value of attribute topic.



4
5
6
# File 'lib/wamp_rails/commands/subscribe.rb', line 4

def topic
  @topic
end

Instance Method Details

#executeObject



16
17
18
19
20
# File 'lib/wamp_rails/commands/subscribe.rb', line 16

def execute
  session.subscribe(topic, handler, options) do |result, error, details|
    self.callback(result, error, details)
  end
end