SObjectizer-5 Extra
Namespaces | Classes | Functions
so_5::extra::enveloped_msg Namespace Reference

Namespaces

 details
 
 errors
 

Classes

class  just_envelope_t
 A very simple implementation of envelope which do nothing except holding a payload. More...
 
class  time_limited_delivery_t
 A special envelope to perform time-limited delivery. More...
 

Functions

template<typename Message , typename... Args>
SO_5_NODISCARD details::payload_holder_t make (Args &&...args)
 A special message builder that allows to wrap a message into an envelope. More...
 

Function Documentation

◆ make()

template<typename Message , typename... Args>
SO_5_NODISCARD details::payload_holder_t so_5::extra::enveloped_msg::make ( Args &&...  args)

A special message builder that allows to wrap a message into an envelope.

This function creates an instance of a specified message type and creates a chain of builders that envelope this instance into an envelope and send the enveloped message as ordinary or delayed/periodic message.

Usage examples:

namespace msg_ns = so_5::extra::enveloped_msg;
// Create message of type my_message, envelop it into my_envelope
// and then send it to the mbox mb1.
so_5::mbox_t mb1 = ...;
msg_ns::make<my_message>(...)
.envelope<my_envelope>(...)
.send_to(mb1);
// Create message of type my_message, envelop it into my_envelope
// and then send it to the mchain ch1.
so_5::mchain_t ch1 = ...;
msg_ns::make<my_message>(...)
.envelope<my_envelope>(...)
.send_to(ch1);
// Create message of type my_message, envelop it into my_envelope
// and then send it to the direct mbox of the agent a1.
so_5::agent_t & a1 = ...;
msg_ns::make<my_message>(...)
.envelope<my_envelope>(...)
.send_to(a1);
// Create message of type my_message, envelop it into my_envelope
// and then send it to the mbox mb1 as delayed message.
// Note that the reference to SObjectizer Environment is necessary.
so_5::environment_t & env = ...;
so_5::mbox_t mb1 = ...;
msg_ns::make<my_message>(...)
.envelope<my_envelope>(...)
.send_delayed_to(env, mb1, 10s);
// Create message of type my_message, envelop it into my_envelope
// and then send it to the mchain ch1 as delayed message.
so_5::mchain_t ch1 = ...;
msg_ns::make<my_message>(...)
.envelope<my_envelope>(...)
.send_delayed_to(ch1, 10s);
// Create message of type my_message, envelop it into my_envelope
// and then send it to the direct mbox of the agent a1 as delayed message.
so_5::agent_t & a1 = ...;
msg_ns::make<my_message>(...)
.envelope<my_envelope>(...)
.send_delayed_to(a1, 10s);
// Create message of type my_message, envelop it into my_envelope
// and then send it to the mbox mb1 as periodic message.
// Note that the reference to SObjectizer Environment is necessary.
so_5::environment_t & env = ...;
so_5::mbox_t mb1 = ...;
auto timer_id = msg_ns::make<my_message>(...)
.envelope<my_envelope>(...)
.send_periodic_to(env, mb1, 10s, 30s);
// Create message of type my_message, envelop it into my_envelope
// and then send it to the mchain ch1 as delayed message.
so_5::mchain_t ch1 = ...;
auto timer_id = msg_ns::make<my_message>(...)
.envelope<my_envelope>(...)
.send_periodic_to(ch1, 10s, 30s);
// Create message of type my_message, envelop it into my_envelope
// and then send it to the direct mbox of the agent a1 as delayed message.
so_5::agent_t & a1 = ...;
auto timer_id = msg_ns::make<my_message>(...)
.envelope<my_envelope>(...)
.send_periodic_to(a1, 10s, 30s);
Since
v.1.2.0

Definition at line 266 of file send_functions.hpp.