54 lines
1.1 KiB
C++
54 lines
1.1 KiB
C++
#ifndef TOON_BRIDGE_H
|
|
#define TOON_BRIDGE_H
|
|
|
|
#include "MessageHandler.h"
|
|
#include "MQTTSettings.h"
|
|
#include "ToonSettings.h"
|
|
#include "WebSocketSubscription.h"
|
|
#include <HttpServer.h>
|
|
#include <MQTT.h>
|
|
#include <Timer.h>
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <string>
|
|
|
|
|
|
namespace ToonBridge {
|
|
namespace Toon {
|
|
|
|
class Bridge
|
|
{
|
|
public:
|
|
Bridge(int port, const ToonSettings& toonSettings, const MQTTSettings& mqttSettings);
|
|
~Bridge();
|
|
|
|
void Wait();
|
|
|
|
private:
|
|
void Start();
|
|
|
|
Http::HttpServer::HttpReply HttpCallback(const std::string& uri, const std::vector<Http::HttpPostData>& postData);
|
|
void ReconnectCallback(WebSocketSubscription* pSubscription);
|
|
void CheckMessageReceived();
|
|
|
|
private:
|
|
std::unique_ptr<Http::HttpServer> m_pHttpServer;
|
|
MQTT::MQTT m_mqttClient;
|
|
MessageHandler m_messageHandler;
|
|
|
|
int m_port;
|
|
ToonSettings m_toonSettings;
|
|
MQTTSettings m_mqttSettings;
|
|
std::unique_ptr<WebSocketSubscription> m_pWebSocketSubscription;
|
|
|
|
Timer::Timer m_messageCheckTimer;
|
|
|
|
std::mutex m_mutex;
|
|
bool m_messageReceived;
|
|
};
|
|
|
|
} // namespace Toon
|
|
} // namespace ToonBridge
|
|
|
|
#endif // TOON_BRIDGE_H
|