mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
71 lines
1.3 KiB
C++
71 lines
1.3 KiB
C++
#pragma once
|
|
|
|
// util
|
|
#include <utils/Logger.h>
|
|
#include <utils/settings.h>
|
|
|
|
// qt
|
|
#include <QVector>
|
|
|
|
class BonjourServiceRegister;
|
|
class QTcpServer;
|
|
class FlatBufferClient;
|
|
class NetOrigin;
|
|
|
|
|
|
///
|
|
/// @brief A TcpServer to receive images of different formats with Google Flatbuffer
|
|
/// Images will be forwarded to all Hyperion instances
|
|
///
|
|
class FlatBufferServer : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
FlatBufferServer(const QJsonDocument& config, QObject* parent = nullptr);
|
|
~FlatBufferServer() override;
|
|
|
|
public slots:
|
|
///
|
|
/// @brief Handle settings update
|
|
/// @param type The type from enum
|
|
/// @param config The configuration
|
|
///
|
|
void handleSettingsUpdate(settings::type type, const QJsonDocument& config);
|
|
|
|
void initServer();
|
|
|
|
private slots:
|
|
///
|
|
/// @brief Is called whenever a new socket wants to connect
|
|
///
|
|
void newConnection();
|
|
|
|
///
|
|
/// @brief is called whenever a client disconnected
|
|
///
|
|
void clientDisconnected();
|
|
|
|
private:
|
|
///
|
|
/// @brief Start the server with current _port
|
|
///
|
|
void startServer();
|
|
|
|
///
|
|
/// @brief Stop server
|
|
///
|
|
void stopServer();
|
|
|
|
|
|
private:
|
|
QTcpServer* _server;
|
|
NetOrigin* _netOrigin;
|
|
Logger* _log;
|
|
int _timeout;
|
|
quint16 _port;
|
|
const QJsonDocument _config;
|
|
BonjourServiceRegister * _serviceRegister = nullptr;
|
|
|
|
QVector<FlatBufferClient*> _openConnections;
|
|
};
|