Class: Vertx::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/vertx/event_bus.rb

Overview

Represents a message received from the event bus

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

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(message)

  @j_del = message
  if message.body.is_a? org.vertx.java.core.json.JsonObject
    @body = JSON.parse(message.body.encode)
  elsif message.body.is_a? org.vertx.java.core.buffer.Buffer
    @body = Buffer.new(message.body)
  else
    @body = message.body
  end
end

Instance Attribute Details

#bodyObject (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.

Parameters:

  • Message (Hash)

    send as reply



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