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.



466
467
468
469
470
471
472
473
474
475
476
# File 'lib/wamp/client/message.rb', line 466

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.



464
465
466
# File 'lib/wamp/client/message.rb', line 464

def options
  @options
end

#requestObject

Returns the value of attribute request.



464
465
466
# File 'lib/wamp/client/message.rb', line 464

def request
  @request
end

#topicObject

Returns the value of attribute topic.



464
465
466
# File 'lib/wamp/client/message.rb', line 464

def topic
  @topic
end

Class Method Details

.parse(params) ⇒ Object



482
483
484
485
486
487
488
489
490
# File 'lib/wamp/client/message.rb', line 482

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



478
479
480
# File 'lib/wamp/client/message.rb', line 478

def self.type
  Types::SUBSCRIBE
end

Instance Method Details

#payloadObject



492
493
494
495
496
497
498
499
500
# File 'lib/wamp/client/message.rb', line 492

def payload

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

  payload
end

#to_sObject



502
503
504
# File 'lib/wamp/client/message.rb', line 502

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