Class: Wamp::Client::Message::Subscribe

Inherits:
Base
  • Object
show all
Defined in:
lib/wamp/client/message.rb

Overview

Subscribe Subscribe request sent by a Subscriber to a Broker to subscribe to a topic. Formats:

[SUBSCRIBE, Request|id, Options|dict, Topic|uri]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Check

included

Constructor Details

#initialize(request, options, topic) ⇒ Subscribe

Returns a new instance of Subscribe.



415
416
417
418
419
420
421
422
423
424
425
# File 'lib/wamp/client/message.rb', line 415

def initialize(request, options, topic)

  self.class.check_id('request', request)
  self.class.check_dict('options', options)
  self.class.check_uri('topic', topic)

  self.request = request
  self.options = options
  self.topic = topic

end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



413
414
415
# File 'lib/wamp/client/message.rb', line 413

def options
  @options
end

#requestObject

Returns the value of attribute request.



413
414
415
# File 'lib/wamp/client/message.rb', line 413

def request
  @request
end

#topicObject

Returns the value of attribute topic.



413
414
415
# File 'lib/wamp/client/message.rb', line 413

def topic
  @topic
end

Class Method Details

.parse(params) ⇒ Object



431
432
433
434
435
436
437
438
439
# File 'lib/wamp/client/message.rb', line 431

def self.parse(params)

  self.check_gte('params list', 4, params.count)
  self.check_equal('message type', self.type, params[0])

  params.shift
  self.new(*params)

end

.typeObject



427
428
429
# File 'lib/wamp/client/message.rb', line 427

def self.type
  Types::SUBSCRIBE
end

Instance Method Details

#payloadObject



441
442
443
444
445
446
447
448
449
# File 'lib/wamp/client/message.rb', line 441

def payload

  payload = [self.class.type]
  payload.push(self.request)
  payload.push(self.options)
  payload.push(self.topic)

  payload
end

#to_sObject



451
452
453
# File 'lib/wamp/client/message.rb', line 451

def to_s
  'SUBSCRIBE > ' + self.payload.to_s
end