bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitsim::network::MqttSubscriber Class Reference

#include <mqtt_subscriber.h>

Inheritance diagram for bitsim::network::MqttSubscriber:
Collaboration diagram for bitsim::network::MqttSubscriber:

Public Member Functions

 MqttSubscriber (const std::string &server, const std::string &topic)
 ~MqttSubscriber () override
std::string topic () const noexcept
bool is_connected () const noexcept
void connect ()
std::optional< std::string > poll (std::chrono::milliseconds timeout=std::chrono::milliseconds(1000))
std::optional< std::string > read (std::chrono::milliseconds timeout=std::chrono::milliseconds::zero())
void message_arrived (mqtt::const_message_ptr msg) override
void publish (const std::string &payload, int_t qos=1, bool retained=false)
void publish (const nlohmann::json &payload, int_t qos=1, bool retained=false)

Detailed Description

A thin wrapper over mqtt::async_client

Constructor & Destructor Documentation

◆ MqttSubscriber()

bitsim::network::MqttSubscriber::MqttSubscriber ( const std::string & server,
const std::string & topic )

◆ ~MqttSubscriber()

bitsim::network::MqttSubscriber::~MqttSubscriber ( )
override

Member Function Documentation

◆ connect()

void bitsim::network::MqttSubscriber::connect ( )

◆ is_connected()

bool bitsim::network::MqttSubscriber::is_connected ( ) const
inlinenoexcept

◆ message_arrived()

void bitsim::network::MqttSubscriber::message_arrived ( mqtt::const_message_ptr msg)
override

◆ poll()

std::optional< std::string > bitsim::network::MqttSubscriber::poll ( std::chrono::milliseconds timeout = std::chrono::milliseconds(1000))

◆ publish() [1/2]

void bitsim::network::MqttSubscriber::publish ( const nlohmann::json & payload,
int_t qos = 1,
bool retained = false )

Publish the JSON payload

Parameters
payload
qos
retained

◆ publish() [2/2]

void bitsim::network::MqttSubscriber::publish ( const std::string & payload,
int_t qos = 1,
bool retained = false )

Publish the payload to the topic that this subscriber listens to

Parameters
payload
qos
retained

◆ read()

std::optional< std::string > bitsim::network::MqttSubscriber::read ( std::chrono::milliseconds timeout = std::chrono::milliseconds::zero())

◆ topic()

std::string bitsim::network::MqttSubscriber::topic ( ) const
inlinenoexcept

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