MQTT.h 657 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef MQTT_H
  2. #define MQTT_H
  3. #include "MQTTMessage.h"
  4. #include <functional>
  5. #include <memory>
  6. #include <string>
  7. namespace MQTT {
  8. class MQTTImpl;
  9. class MQTT
  10. {
  11. public:
  12. MQTT(const std::string& hostname, int port, int threads = 3);
  13. ~MQTT();
  14. MQTT(const MQTT&) = delete;
  15. public:
  16. typedef std::function<void(const MQTTMessage&)> CallbackMethod;
  17. public:
  18. bool Send(const MQTTMessage& message);
  19. bool Subscribe(const std::string& topic);
  20. void Unsubscribe(const std::string& topic);
  21. size_t Connect(CallbackMethod function);
  22. void Disconnect(size_t connection);
  23. private:
  24. std::unique_ptr<MQTTImpl> m_pMQTTImpl;
  25. };
  26. } // namespace MQTT
  27. #endif // MQTT_H