MQTT ready to use

change subscription logic - now keep subscriptions independently from connecting state. No unregisters on disconnect, but resubscriptions on connect. So one-time subscription on app start and just connect() on lost connection - all subscriptions keeps
This commit is contained in:
2026-05-29 09:56:29 +03:00
parent 38d09e272c
commit afb4ae8126
3 changed files with 70 additions and 45 deletions
+2 -1
View File
@@ -50,7 +50,6 @@ public:
void connect(const PIString & address, const PIString & client, const PIString & username = {}, const PIString & password = {});
void disconnect();
void subscribe(const PIString & topic, MessageFunction functor, QoS qos = QoS::Level1);
template<typename T>
@@ -68,6 +67,8 @@ public:
bool isConnecting() const { return m_status == Connecting; }
bool isConnected() const { return m_status == Connected; }
PIStringList usedTopics() const;
EVENT0(connected);
EVENT1(disconnected, PIMQTT::Error, code);
EVENT1(receivedUnhandled, PIMQTT::MessageConst, message);