Participants in several processes, on one machine or several, that meet on an MQTT broker.
More...
#include <mqtt_transport.h>
|
| | MQTT_Transport (const std::string &broker, const std::string &world) |
| void | publish (const std::string &bytes) override |
| | Send bytes to every other participant.
|
| std::optional< std::string > | receive (std::chrono::milliseconds timeout) override |
| | The next message from another participant, waiting at most timeout.
|
| virtual | ~Transport ()=default |
|
| static std::string | topic (const std::string &world) |
Participants in several processes, on one machine or several, that meet on an MQTT broker.
Every participant of a world publishes to and subscribes to the topic "bitsim/world/<world>", so it also receives its own messages, which Synchroniser ignores. The messages are published with quality of service 0: a lost state is replaced by the next, or sent again by the synchroniser in lockstep. A robot on the network, a Raspberry Pi for example, joins the world by publishing StateMessage::encode() to the same topic.
◆ MQTT_Transport()
| bitsim::distributed::MQTT_Transport::MQTT_Transport |
( |
const std::string & | broker, |
|
|
const std::string & | world ) |
- Parameters
-
| broker | the address of the broker, "tcp://localhost:1883" for example |
| world | the name of the world; participants of different worlds do not meet |
◆ publish()
| void bitsim::distributed::MQTT_Transport::publish |
( |
const std::string & | bytes | ) |
|
|
overridevirtual |
◆ receive()
| std::optional< std::string > bitsim::distributed::MQTT_Transport::receive |
( |
std::chrono::milliseconds | timeout | ) |
|
|
overridevirtual |
◆ topic()
| std::string bitsim::distributed::MQTT_Transport::topic |
( |
const std::string & | world | ) |
|
|
inlinestatic |
The documentation for this class was generated from the following files: