MQTT.h 610 B

123456789101112131415161718192021222324252627282930313233343536
  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);
  13. ~MQTT();
  14. public:
  15. typedef std::function<void(const MQTTMessage&)> CallbackMethod;
  16. public:
  17. bool Send(const MQTTMessage& message);
  18. bool Subscribe(const std::string& topic);
  19. void Unsubscribe(const std::string& topic);
  20. size_t Connect(CallbackMethod function);
  21. void Disconnect(size_t connection);
  22. private:
  23. std::unique_ptr<MQTTImpl> m_pMQTTImpl;
  24. };
  25. } // namespace MQTT
  26. #endif // MQTT_H