8 #include <Poco/AtomicCounter.h>
9 #include <Poco/Event.h>
10 #include <Poco/Mutex.h>
11 #include <Poco/SharedPtr.h>
12 #include <Poco/Timespan.h>
14 #include <mosquittopp.h>
16 #include "loop/StoppableRunnable.h"
17 #include "net/MqttClient.h"
18 #include "util/Loggable.h"
33 protected mosqpp::mosquittopp,
37 typedef Poco::SharedPtr<MosquittoClient> Ptr;
50 void setHost(
const std::string &host);
51 void setPort(
int port);
56 void setSubTopics(
const std::list<std::string> &subTopics);
64 void setClientID(
const std::string &
id);
65 std::string clientID()
const;
88 virtual std::string buildClientID()
const;
101 bool initConnection();
103 void subscribeToAll();
105 void throwMosquittoError(
int returnCode)
const;
113 void on_message(
const struct mosquitto_message *message)
override;
121 std::string m_clientID;
123 Poco::Timespan m_reconnectTimeout;
125 std::set<std::string> m_subTopics;
126 Poco::AtomicCounter m_stop;
127 Poco::Event m_receiveEvent;
128 Poco::Event m_reconnectEvent;
129 Poco::FastMutex m_queueMutex;
130 std::queue<MqttMessage> m_msgQueue;
void run() override
Definition: MosquittoClient.cpp:157
void setReconnectTimeout(const Poco::Timespan &timeout)
Definition: MosquittoClient.cpp:219
Definition: MqttClient.h:10
Definition: MqttMessage.h:7
void connect()
Definition: MosquittoClient.cpp:85
void setSubTopics(const std::list< std::string > &subTopics)
Definition: MosquittoClient.cpp:184
void stop() override
Definition: MosquittoClient.cpp:177
void publish(const MqttMessage &msq) override
Definition: MosquittoClient.cpp:72
Definition: MosquittoClient.h:31
Definition: Loggable.h:19
Definition: StoppableRunnable.h:8
MqttMessage receive(const Poco::Timespan &timeout) override
Definition: MosquittoClient.cpp:108