Bridge.h 975 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef TOON_BRIDGE_H
  2. #define TOON_BRIDGE_H
  3. #include "MessageHandler.h"
  4. #include "MQTTSettings.h"
  5. #include "ToonSettings.h"
  6. #include "WebSocketSubscription.h"
  7. #include <HttpServer.h>
  8. #include <MQTT.h>
  9. #include <memory>
  10. #include <string>
  11. namespace ToonBridge {
  12. namespace Toon {
  13. class Bridge
  14. {
  15. public:
  16. Bridge(int port, const ToonSettings& toonSettings, const MQTTSettings& mqttSettings);
  17. ~Bridge();
  18. void Wait();
  19. private:
  20. void Start();
  21. Http::HttpServer::HttpReply HttpCallback(const std::string& uri, const std::vector<Http::HttpPostData>& postData);
  22. void TimeToLiveCallback(WebSocketSubscription* pSubscription, int timeToLive);
  23. private:
  24. std::unique_ptr<Http::HttpServer> m_pHttpServer;
  25. MQTT::MQTT m_mqttClient;
  26. MessageHandler m_messageHandler;
  27. int m_port;
  28. ToonSettings m_toonSettings;
  29. MQTTSettings m_mqttSettings;
  30. std::unique_ptr<WebSocketSubscription> m_pWebSocketSubscription;
  31. };
  32. } // namespace Toon
  33. } // namespace ToonBridge
  34. #endif // TOON_BRIDGE_H