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

Outgoing message. More...

#include <outgoing_message.h>

Public Types

typedef long long outgoing_message_id
 Outgoing message identifier type.
 

Public Member Functions

 outgoing_message ()
 Constructor. More...
 
void reset (details::outgoing_message_manager &manager, details::outgoing_message_info &info)
 
void disown_info_object ()
 
message_state get_state () const
 Returns the state of this message.
 
message_state get_state (std::size_t &sent_bytes, std::size_t &total_byte_count) const
 Returns the state of this message. More...
 
void wait_for_transmission () const
 Waits for the transmission to finish. More...
 
bool wait_for_transmission (std::size_t relative_timeout) const
 Waits for the transmission to finish or until timeout expires. More...
 
void wait_for_completion () const
 Waits for the full message roundtrip. More...
 
bool wait_for_completion (std::size_t relative_timeout) const
 Waits for the message roundtrip or until timeout expires. More...
 
const parametersget_header () const
 Provides access to the reply header.
 
const parametersget_reply () const
 Provides access to the reply content.
 
const std::vector< char > & get_raw_reply () const
 Provides access to the reply content. More...
 
parametersextract_reply ()
 Extracts the reply content. More...
 
const std::string & get_exception_msg () const
 Returns the exception message. More...
 
outgoing_message_id get_message_id () const
 Returns the internal message id. More...
 

Detailed Description

Outgoing message.

The handler allowing to track the progress of outgoing message, inspect its state and to obtain the reply content.

Note: The objects of this class can be safely used from multiple threads.

Constructor & Destructor Documentation

◆ outgoing_message()

yami::outgoing_message::outgoing_message ( )

Constructor.

Creates uninitialized outgoing message object.

Member Function Documentation

◆ extract_reply()

parameters * yami::outgoing_message::extract_reply ( )

Extracts the reply content.

The reply 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_exception_msg()

const std::string & yami::outgoing_message::get_exception_msg ( ) const

Returns the exception message.

This function can be called when the state of message is "rejected".

◆ get_message_id()

outgoing_message_id yami::outgoing_message::get_message_id ( ) const

Returns the internal message id.

This function can be useful together with asynchronous callbacks, the message id is the one that was returned by agent::send.

◆ get_raw_reply()

const std::vector< char > & yami::outgoing_message::get_raw_reply ( ) const

Provides access to the reply content.

Note: this function can be used only when the data is delivered in the raw buffer form.

◆ get_state()

message_state yami::outgoing_message::get_state ( std::size_t &  sent_bytes,
std::size_t &  total_byte_count 
) const

Returns the state of this message.

This function allows to inspect the progress of the message transmission. During transmission the sent_bytes value is always smaller than total_byte_count. When these two values become equal, it means that the transmission was either succesful or abandoned.

Parameters
sent_bytesThe number of bytes that were already sent for this message.
total_byte_countThe total number of bytes that should be sent for this message.

◆ wait_for_completion() [1/2]

void yami::outgoing_message::wait_for_completion ( ) const

Waits for the full message roundtrip.

Waits for the full message roundtrip - that is, for some confirmation that the message has been received and reacted upon by the target agent. After this function returns the state of the message is either abandoned, replied or rejected.

Note: This function should not be called if the intended semantics of the message is "one-way" - in this case this function would block indefinitely.

◆ wait_for_completion() [2/2]

bool yami::outgoing_message::wait_for_completion ( std::size_t  relative_timeout) const

Waits for the message roundtrip or until timeout expires.

Waits for the full message roundtrip or until the given relative timeout expires.

Parameters
relative_timeoutThe relative timeout in milliseconds.
Returns
  • true if the wait completed before the timeout
  • false if the timeout expired before the message was completed

◆ wait_for_transmission() [1/2]

void yami::outgoing_message::wait_for_transmission ( ) const

Waits for the transmission to finish.

Waits for the transmission to finish - that is, to either send all the message data or to abandon it. After this function returns the state of the message is either transmitted, abandoned, replied or rejected.

◆ wait_for_transmission() [2/2]

bool yami::outgoing_message::wait_for_transmission ( std::size_t  relative_timeout) const

Waits for the transmission to finish or until timeout expires.

Waits for the transmission to finish or until the given relative timeout expires.

Parameters
relative_timeoutThe relative timeout in milliseconds.
Returns
  • true if the wait completed before the timeout
  • false if the timeout expired before the message was fully transmitted

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