A class to store messages to be delivered using a comms model. This class should be used in combination with a specific comms model that implements the ICommsModel interface. More...
#include <Broker.hh>
Public Member Functions | |
Broker () | |
Constructor. More... | |
MsgManager & | DataManager () |
Get a mutable reference to the message manager. More... | |
void | DeliverMsgs () |
Process all the messages in the inbound queue and deliver them to the destination clients. More... | |
void | Load (std::shared_ptr< const sdf::Element > _sdf) |
Configure the broker via SDF. More... | |
void | Lock () |
Lock the mutex to access the message manager. More... | |
bool | OnBind (const ignition::msgs::StringMsg_V &_req, ignition::msgs::Boolean &_rep) |
This method associates an address with a client topic used as callback for receiving messages. This is a client requirement to start receiving messages. More... | |
void | OnMsg (const ignition::msgs::Dataframe &_msg) |
Callback executed to process a communication request from one of the clients. More... | |
void | OnUnbind (const ignition::msgs::StringMsg_V &_req) |
Unbind a given client address. The client associated to this address will not receive any more messages. More... | |
void | SetTime (const std::chrono::steady_clock::duration &_time) |
Set the current time. More... | |
void | Start () |
Start handling comms services. More... | |
std::chrono::steady_clock::duration | Time () const |
Get the current time. More... | |
void | Unlock () |
Unlock the mutex to access the message manager. More... | |
Detailed Description
A class to store messages to be delivered using a comms model. This class should be used in combination with a specific comms model that implements the ICommsModel interface.
- See also
- ICommsModel.hh The broker maintains two queues: inbound and outbound. When a client sends a communication request, we'll store it in the outbound queue of the sender's address. When the comms model decides that a message needs to be delivered to one of the destination, it'll be stored in the inbound queue of the destination's address.
The main goal of this class is to receive the comms requests, stamp the time, and place them in the appropriate outbound queue, as well as deliver the messages that are in the inbound queues.
The instance of the comms model is responsible for moving around the messages from the outbound queues to the inbound queues.
The broker can be configured with the following SDF parameters:
- Optional parameters: <broker> Element used to capture the broker parameters. This block can contain any of the next parameters: <messages_topic>: Topic name where the broker receives all the incoming messages. The default value is "/broker/msgs" <bind_service>: Service name used to bind an address. The default value is "/broker/bind" <unbind_service>: Service name used to unbind from an address. The default value is "/broker/unbind"
Here's an example: <plugin filename="ignition-gazebo-perfect-comms-system" name="ignition::gazebo::systems::PerfectComms"> <broker> <messages_topic>/broker/inbound</messages_topic> <bind_service>/broker/bind_address</bind_service> <unbind_service>/broker/unbind_address</unbind_service> </broker> </plugin>
Constructor & Destructor Documentation
◆ Broker()
Broker | ( | ) |
Constructor.
Member Function Documentation
◆ DataManager()
MsgManager& DataManager | ( | ) |
Get a mutable reference to the message manager.
- Returns
- The mutable reference.
◆ DeliverMsgs()
void DeliverMsgs | ( | ) |
Process all the messages in the inbound queue and deliver them to the destination clients.
◆ Load()
void Load | ( | std::shared_ptr< const sdf::Element > | _sdf | ) |
Configure the broker via SDF.
- Parameters
-
[in] _sdf The SDF Element associated with the broker parameters.
◆ Lock()
void Lock | ( | ) |
Lock the mutex to access the message manager.
◆ OnBind()
bool OnBind | ( | const ignition::msgs::StringMsg_V & | _req, |
ignition::msgs::Boolean & | _rep | ||
) |
This method associates an address with a client topic used as callback for receiving messages. This is a client requirement to start receiving messages.
- Parameters
-
[in] _req Bind request containing the following content: _req[0] Client address. _req[1] Model name associated to the address. _req[2] Client subscription topic. [out] _rep Unused
- Returns
- True when the bind service succeeded or false otherwise.
◆ OnMsg()
void OnMsg | ( | const ignition::msgs::Dataframe & | _msg | ) |
Callback executed to process a communication request from one of the clients.
- Parameters
-
[in] _msg The message from the client.
◆ OnUnbind()
void OnUnbind | ( | const ignition::msgs::StringMsg_V & | _req | ) |
Unbind a given client address. The client associated to this address will not receive any more messages.
- Parameters
-
[in] _req Bind request containing the following content: _req[0] Client address. _req[1] Client subscription topic.
◆ SetTime()
void SetTime | ( | const std::chrono::steady_clock::duration & | _time | ) |
Set the current time.
- Parameters
-
[in] _time Current time.
◆ Start()
void Start | ( | ) |
Start handling comms services.
This function allows us to wait to advertise capabilities to clients until the broker has been entirely initialized.
◆ Time()
std::chrono::steady_clock::duration Time | ( | ) | const |
Get the current time.
- Returns
- Current time.
◆ Unlock()
void Unlock | ( | ) |
Unlock the mutex to access the message manager.
The documentation for this class was generated from the following file: