Class: WampClient::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.



482
483
484
485
486
487
488
489
490
491
492
# File 'lib/wamp_client/message.rb', line 482

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.



480
481
482
# File 'lib/wamp_client/message.rb', line 480

def options
  @options
end

#requestObject

Returns the value of attribute request.



480
481
482
# File 'lib/wamp_client/message.rb', line 480

def request
  @request
end

#topicObject

Returns the value of attribute topic.



480
481
482
# File 'lib/wamp_client/message.rb', line 480

def topic
  @topic
end

Class Method Details

.parse(params) ⇒ Object



498
499
500
501
502
503
504
505
506
# File 'lib/wamp_client/message.rb', line 498

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



494
495
496
# File 'lib/wamp_client/message.rb', line 494

def self.type
  Types::SUBSCRIBE
end

Instance Method Details

#payloadObject



508
509
510
511
512
513
514
515
# File 'lib/wamp_client/message.rb', line 508

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

  payload
end

#to_sObject



517
518
519
# File 'lib/wamp_client/message.rb', line 517

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