Class: Vertx::Message
- Inherits:
-
Object
- Object
- Vertx::Message
- Defined in:
- lib/vertx/event_bus.rb
Overview
Represents a message received from the event bus
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Instance Method Summary collapse
-
#initialize(message) ⇒ Message
constructor
A new instance of Message.
-
#reply(reply, &reply_handler) ⇒ Object
Reply to this message.
Constructor Details
#initialize(message) ⇒ Message
Returns a new instance of Message.
175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/vertx/event_bus.rb', line 175 def initialize() @j_del = if .body.is_a? org.vertx.java.core.json.JsonObject @body = JSON.parse(.body.encode) elsif .body.is_a? org.vertx.java.core.buffer.Buffer @body = Buffer.new(.body) else @body = .body end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
172 173 174 |
# File 'lib/vertx/event_bus.rb', line 172 def body @body end |
Instance Method Details
#reply(reply, &reply_handler) ⇒ Object
Reply to this message. If the message was sent specifying a receipt handler, that handler will be called when it has received a reply. If the message wasn’t sent specifying a receipt handler this method does nothing. Replying to a message this way is equivalent to sending a message to an address which is the same as the message id of the original message.
193 194 195 196 197 198 199 200 201 |
# File 'lib/vertx/event_bus.rb', line 193 def reply(reply, &reply_handler) raise "A reply message must be specified" if reply == nil reply = EventBus.convert_msg(reply) if reply_handler != nil @j_del.reply(reply, InternalHandler.new(reply_handler)) else @j_del.reply(reply) end end |