Class: WampClient::Message::Publish
- Defined in:
- lib/wamp_client/message.rb
Overview
Publish Sent by a Publisher to a Broker to publish an event. Formats:
[PUBLISH, Request|id, Options|dict, Topic|uri]
[PUBLISH, Request|id, Options|dict, Topic|uri, Arguments|list]
[PUBLISH, Request|id, Options|dict, Topic|uri, Arguments|list, ArgumentsKw|dict]
Instance Attribute Summary collapse
-
#arguments ⇒ Object
Returns the value of attribute arguments.
-
#argumentskw ⇒ Object
Returns the value of attribute argumentskw.
-
#options ⇒ Object
Returns the value of attribute options.
-
#request ⇒ Object
Returns the value of attribute request.
-
#topic ⇒ Object
Returns the value of attribute topic.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(request, options, topic, arguments = nil, argumentskw = nil) ⇒ Publish
constructor
A new instance of Publish.
- #payload ⇒ Object
- #to_s ⇒ Object
Methods included from Check
Constructor Details
#initialize(request, options, topic, arguments = nil, argumentskw = nil) ⇒ Publish
Returns a new instance of Publish.
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
# File 'lib/wamp_client/message.rb', line 386 def initialize(request, , topic, arguments=nil, argumentskw=nil) self.class.check_id('request', request) self.class.check_dict('options', ) self.class.check_uri('topic', topic) self.class.check_list('arguments', arguments, true) self.class.check_dict('argumentskw', argumentskw, true) self.request = request self. = self.topic = topic self.arguments = arguments self.argumentskw = argumentskw end |
Instance Attribute Details
#arguments ⇒ Object
Returns the value of attribute arguments.
384 385 386 |
# File 'lib/wamp_client/message.rb', line 384 def arguments @arguments end |
#argumentskw ⇒ Object
Returns the value of attribute argumentskw.
384 385 386 |
# File 'lib/wamp_client/message.rb', line 384 def argumentskw @argumentskw end |
#options ⇒ Object
Returns the value of attribute options.
384 385 386 |
# File 'lib/wamp_client/message.rb', line 384 def @options end |
#request ⇒ Object
Returns the value of attribute request.
384 385 386 |
# File 'lib/wamp_client/message.rb', line 384 def request @request end |
#topic ⇒ Object
Returns the value of attribute topic.
384 385 386 |
# File 'lib/wamp_client/message.rb', line 384 def topic @topic end |
Class Method Details
.parse(params) ⇒ Object
406 407 408 409 410 411 412 413 414 |
# File 'lib/wamp_client/message.rb', line 406 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 |
Instance Method Details
#payload ⇒ Object
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
# File 'lib/wamp_client/message.rb', line 416 def payload self.arguments ||= [] self.argumentskw ||= {} payload = [self.class.type] payload.push(self.request) payload.push(self.) payload.push(self.topic) return payload if (self.arguments.empty? and self.argumentskw.empty?) payload.push(self.arguments) return payload if (self.argumentskw.empty?) payload.push(self.argumentskw) payload end |
#to_s ⇒ Object
434 435 436 |
# File 'lib/wamp_client/message.rb', line 434 def to_s 'PUBLISH > ' + self.payload.to_s end |