YAMI4 C++ Library 2.0.0
Messaging Solution for Distributed Systems
Loading...
Searching...
No Matches
Public Member Functions | List of all members
yami::incoming_message Class Reference

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 parametersget_header () const
 Provides access to the message header.
 
const parametersget_parameters () const
 Provides access to the message content.
 
parametersextract_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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ incoming_message()

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.

Member Function Documentation

◆ extract_parameters()

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.

◆ get_raw_content()

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.

◆ get_source()

const std::string & yami::incoming_message::get_source ( ) const

Returns the source of this incoming message.

Returns
The name of the originating endpoint from where this incoming message has been sent.

◆ reject()

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.

Parameters
reasonArbitrary text that will be visible by the message sender as a reason for rejection.
priorityThe priority of the rejection.

◆ reply()

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.

Parameters
bodyThe content of the reply.
priorityThe priority of the reply.

The documentation for this class was generated from the following file: