/** * Websocket interface to participant positions * $Id$ * $HeadURL$ * $Author$ * Created by Justus Hertel, SLSE, 2017-01-11 */ #pragma once #include #include #include "building_control_handler.h" #include "logger.h" // Websocket Server for WebApplication namespace Buildings { class WebSocketHandler final: public QObject { Q_OBJECT public: explicit WebSocketHandler(const std::shared_ptr &buildingControlHandler, QObject *parent = nullptr); ~WebSocketHandler(); bool init(quint16 listenPort = 0); bool init(const QPair &portRange); bool isConnected() const { return !m_webSockets.isEmpty(); } quint16 listenPort() const { return m_webSocketServer->serverPort(); } bool sendPosition(); private: bool sendTelegramInternal() const; bool sendbuildingInfos() const; QJsonObject ObjectFromString(const QString& in); void triggerFlashlight(const QString &message); private Q_SLOTS: void onNewMessage(const QString &message); void onNewConnection(); void onWebSocketDisconnected(); private: std::shared_ptr m_buildingControlHandler; ///< Pointer to VOM DDS handler QWebSocketServer* m_webSocketServer = nullptr; QVector m_webSockets; LOGGER_T m_logger; }; }