YAMI4 C++ Library 2.0.0
Messaging Solution for Distributed Systems
|
Incoming message. More...
#include <incoming_message.h>
Public Member Functions | |
incoming_message (details::agent_impl &agent, details::incoming_message_info &info) | |
incoming_message (incoming_message &other) | |
Moving constructor. More... | |
const std::string & | get_source () const |
Returns the source of this incoming message. More... | |
const std::string & | get_object_name () const |
Returns the destination object name. | |
const std::string & | get_message_name () const |
Returns the message name. | |
const parameters & | get_header () const |
Provides access to the message header. | |
const parameters & | get_parameters () const |
Provides access to the message content. | |
parameters * | extract_parameters () |
Extracts the message content. More... | |
const std::vector< char > & | get_raw_content () const |
Provides access to the raw buffer of message content. More... | |
long long | get_message_id () const |
Extracts the server's message identifier. | |
void | reply (const serializable &body=parameters(), std::size_t priority=0) |
Sends back the reply. More... | |
void | reject (const std::string &reason=std::string(), std::size_t priority=0) |
Sends back the rejection (exception) notification. More... | |
Incoming message.
The handler allowing to inspect the details of the incoming message and sent back replies or rejection notifications.
The user code interacts with objects of this type mainly in the functors that are provided during object registration and that are later called back when the incoming message arrives. The handler objects can be stored aside for further processing even after the callback returns, but should not be kept alive longer than the agent itself.
Note: The objects of this class are not supposed to be used from multiple threads.
yami::incoming_message::incoming_message | ( | incoming_message & | other | ) |
Moving constructor.
This class was designed to be non-copyable, but allows "destructive copy" similar to that of std::unique_ptr
. This functionality is enough for the user to store aside the handler for further processing, but the original object is no longer valid and all attempts to use it will result in the exception.
parameters * yami::incoming_message::extract_parameters | ( | ) |
Extracts the message content.
The message content is moved to the caller and the caller becomes the owner of the parameters
object. This object itself is no longer holding any references to the content and therefore any future attempts to access it will result in the exception.
const std::vector< char > & yami::incoming_message::get_raw_content | ( | ) | const |
Provides access to the raw buffer of message content.
Note: this function can be called only if the messages are delivered in the form of raw (not already serialized) buffers.
const std::string & yami::incoming_message::get_source | ( | ) | const |
Returns the source of this incoming message.
void yami::incoming_message::reject | ( | const std::string & | reason = std::string() , |
std::size_t | priority = 0 |
||
) |
Sends back the rejection (exception) notification.
Sends back the rejection to the message identified by this object. The rejection (or reply) can be sent only once.
reason | Arbitrary text that will be visible by the message sender as a reason for rejection. |
priority | The priority of the rejection. |
void yami::incoming_message::reply | ( | const serializable & | body = parameters() , |
std::size_t | priority = 0 |
||
) |
Sends back the reply.
Sends back the reply to the message identified by this object. The reply (or rejection) can be sent only once.
body | The content of the reply. |
priority | The priority of the reply. |