Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Websocket interface for building control unit
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2017-01-30
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QQueue>
|
||||
#include <QWebSocketServer>
|
||||
#include <memory>
|
||||
#include <logger.h>
|
||||
|
||||
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<Telegrams::BaseTelegram> &tele);
|
||||
void webSocketConnected(QWebSocket *ws);
|
||||
private Q_SLOTS:
|
||||
void onNewConnection();
|
||||
void onWebSocketDisconnected();
|
||||
void onTextMessageReceived(const QString &msg);
|
||||
private:
|
||||
QWebSocketServer *m_webSocketServer;
|
||||
QSet<QWebSocket *> m_webSockets;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
} // namespace Json
|
||||
} // namespace BuildingControlUnit
|
||||
Reference in new issue
Block a user