/** * Websocket interface for building control unit * $Id$ * $HeadURL$ * $Author$ * Created by Christian Ehrlicher, SLSE, 2017-01-30 */ #pragma once #include #include #include #include #include namespace BuildingControlUnit { namespace Json { namespace Telegrams { class BaseTelegram; } class WebSocketHandler : public QObject { Q_OBJECT public: explicit WebSocketHandler(QObject *parent = nullptr); ~WebSocketHandler(); bool init(quint16 listenPort); bool isConnected() const { return !m_webSockets.isEmpty(); } bool sendTelegram(const Telegrams::BaseTelegram *tele, QWebSocket *wsDirect); Q_SIGNALS: void telegramReceived(const std::shared_ptr &tele); void webSocketConnected(QWebSocket *ws); private Q_SLOTS: void onNewConnection(); void onWebSocketDisconnected(); void onTextMessageReceived(const QString &msg); private: QWebSocketServer *m_webSocketServer; QSet m_webSockets; LOGGER_T m_logger; }; } // namespace Json } // namespace BuildingControlUnit