62 lines
1.1 KiB
C++
Executable File
62 lines
1.1 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* Websocket Server to connect to NGSConnector
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <QWebSocket>
|
|
#include <QWebSocketServer>
|
|
|
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
|
|
|
#include <memory>
|
|
|
|
namespace HighLevelArchitecture
|
|
{
|
|
|
|
class NgsHandler;
|
|
|
|
//
|
|
// class WsInterface
|
|
//
|
|
class WsInterface : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit WsInterface(std::shared_ptr<NgsHandler> ngsHandler, QObject *parent = 0);
|
|
~WsInterface();
|
|
|
|
bool init(quint16 listenPort);
|
|
bool isConnected() const { return !m_clients.isEmpty(); }
|
|
|
|
signals:
|
|
|
|
private:
|
|
QWebSocketServer *m_wsServer;
|
|
QSet<QWebSocket *> m_clients;
|
|
|
|
std::shared_ptr<NgsHandler> m_ngsHandler;
|
|
|
|
NGL::INGLLogger &m_logger;
|
|
|
|
private slots:
|
|
// From Websocket:
|
|
void onNewConnection();
|
|
void onWebSocketDisconnected();
|
|
void onError(QAbstractSocket::SocketError error);
|
|
void onTextMessageReceived(const QString &msg);
|
|
|
|
void processMessage(const QByteArray baJson);
|
|
|
|
// From NGSConnector:
|
|
// empty
|
|
};
|
|
|
|
} // HighLevelArchitecture
|