NRP Core  1.4.1
NRPMQTTProxy Class Reference

#include <nrp_mqtt_proxy.h>

Public Member Functions

 NRPMQTTProxy ()=delete
 
 NRPMQTTProxy (const NRPMQTTProxy &)=delete
 
 NRPMQTTProxy (NRPMQTTProxy &&)=delete
 
NRPMQTTProxyoperator= (const NRPMQTTProxy &)=delete
 
NRPMQTTProxyoperator= (NRPMQTTProxy &&)=delete
 
void subscribe (const std::string &address, const std::function< void(const std::string &)> &callback)
 Subscribe to MQTT topic 'address' with callback function 'callback'. More...
 
void publish (const std::string &address, const std::string &msg, bool retained=false)
 Publishes 'msg' to MQTT topic 'address'. More...
 
bool isConnected ()
 Check connection status to broker. More...
 
void disconnect ()
 Disconnects client from MQTT Broker. More...
 
void clearRetained ()
 Clear all topics with retain messages by sending an empty msg. More...
 

Static Public Member Functions

static NRPMQTTProxygetInstance ()
 Get singleton instance of NRPMQTTProxy. More...
 
static NRPMQTTProxyresetInstance (const nlohmann::json &clientParams)
 Reset singleton instance. More...
 

Protected Attributes

bool _doBypassBroker = false
 If true, msgs are published directly to subscriber callbacks, without going through the MQTT broker. Only for testing. More...
 

Friends

class EventLoop_EVENT_LOOP_ENGINE_Test
 

Constructor & Destructor Documentation

◆ NRPMQTTProxy() [1/3]

NRPMQTTProxy::NRPMQTTProxy ( )
delete

◆ NRPMQTTProxy() [2/3]

NRPMQTTProxy::NRPMQTTProxy ( const NRPMQTTProxy )
delete

◆ NRPMQTTProxy() [3/3]

NRPMQTTProxy::NRPMQTTProxy ( NRPMQTTProxy &&  )
delete

Member Function Documentation

◆ clearRetained()

void NRPMQTTProxy::clearRetained ( )

Clear all topics with retain messages by sending an empty msg.

◆ disconnect()

void NRPMQTTProxy::disconnect ( )

Disconnects client from MQTT Broker.

◆ getInstance()

NRPMQTTProxy & NRPMQTTProxy::getInstance ( )
static

Get singleton instance of NRPMQTTProxy.

◆ isConnected()

bool NRPMQTTProxy::isConnected ( )

Check connection status to broker.

◆ operator=() [1/2]

NRPMQTTProxy& NRPMQTTProxy::operator= ( const NRPMQTTProxy )
delete

◆ operator=() [2/2]

NRPMQTTProxy& NRPMQTTProxy::operator= ( NRPMQTTProxy &&  )
delete

◆ publish()

void NRPMQTTProxy::publish ( const std::string &  address,
const std::string &  msg,
bool  retained = false 
)

Publishes 'msg' to MQTT topic 'address'.

◆ resetInstance()

NRPMQTTProxy & NRPMQTTProxy::resetInstance ( const nlohmann::json clientParams)
static

Reset singleton instance.

◆ subscribe()

void NRPMQTTProxy::subscribe ( const std::string &  address,
const std::function< void(const std::string &)> &  callback 
)

Subscribe to MQTT topic 'address' with callback function 'callback'.

Friends And Related Function Documentation

◆ EventLoop_EVENT_LOOP_ENGINE_Test

friend class EventLoop_EVENT_LOOP_ENGINE_Test
friend

Member Data Documentation

◆ _doBypassBroker

bool NRPMQTTProxy::_doBypassBroker = false
protected

If true, msgs are published directly to subscriber callbacks, without going through the MQTT broker. Only for testing.


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