BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
Public Types | Public Member Functions | Protected Member Functions
BeeeOn::MosquittoClient Class Reference

#include <MosquittoClient.h>

Inheritance diagram for BeeeOn::MosquittoClient:
BeeeOn::Loggable BeeeOn::StoppableRunnable BeeeOn::MqttClient BeeeOn::GatewayMosquittoClient

Public Types

typedef Poco::SharedPtr
< MosquittoClient
Ptr
 
- Public Types inherited from BeeeOn::StoppableRunnable
typedef Poco::SharedPtr
< StoppableRunnable
Ptr
 
- Public Types inherited from BeeeOn::MqttClient
typedef Poco::SharedPtr
< MqttClient
Ptr
 

Public Member Functions

void run () override
 
void stop () override
 
void setHost (const std::string &host)
 
void setPort (int port)
 
void setSubTopics (const std::list< std::string > &subTopics)
 
void setReconnectTimeout (const Poco::Timespan &timeout)
 
void setClientID (const std::string &id)
 
std::string clientID () const
 
void publish (const MqttMessage &msq) override
 
MqttMessage receive (const Poco::Timespan &timeout) override
 

Protected Member Functions

virtual std::string buildClientID () const
 
void connect ()
 

Detailed Description

Mosquitto client runs in a thread. Before its run it is necessary to set following parameters:

Member Function Documentation

void MosquittoClient::connect ( )
protected

Non-blocking connection to broker request. After set client name must be call MosquittoClient::connect();

void MosquittoClient::publish ( const MqttMessage msq)
overridevirtual

Publish a message on a given topic.

Implements BeeeOn::MqttClient.

MqttMessage MosquittoClient::receive ( const Poco::Timespan &  timeout)
overridevirtual

Waiting for a new message according to given timeout. Returns message, if some message is in queue, otherwise waiting for a new message or timeout exception.

This method should not be called by multiple threads, received message could be given to only one thread.

Timeout:

  • 0 - non-blocking
  • negative - blocking
  • positive blocking with timeout

Implements BeeeOn::MqttClient.

void MosquittoClient::run ( )
override

Keeps communication between the client and broker working.

See Also
: https://mosquitto.org/api/files/mosquitto-h.html#mosquitto_loop
void MosquittoClient::setReconnectTimeout ( const Poco::Timespan &  timeout)

Timeout between reconnecting to the server when server connection is lost.

void MosquittoClient::setSubTopics ( const std::list< std::string > &  subTopics)

Subscribe to a topic.

void MosquittoClient::stop ( )
overridevirtual

Stop the runnable. The call should not block.

Implements BeeeOn::StoppableRunnable.


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