85 lines
2.3 KiB
C++
Executable File
85 lines
2.3 KiB
C++
Executable File
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "lts_projection_workstation_export.h"
|
|
#include "vnc_server_manager.h"
|
|
#include "WebSocket/messages.h"
|
|
#include "logger.h"
|
|
|
|
#include <LtsWebSocket/client_connection.h>
|
|
|
|
#include <QObject>
|
|
#include <QPair>
|
|
|
|
namespace LtsWebSocket { class LtsWebSocketServer; }
|
|
namespace LtsProjectionWorkstation
|
|
{
|
|
|
|
struct LoginInformation
|
|
{
|
|
LoginInformation() = default;
|
|
LoginInformation(int userId, int priority, int exerciseId, const QByteArray &settingsData)
|
|
: m_settingsData(settingsData), m_userId(userId), m_priority(priority), m_exerciseId(exerciseId) {}
|
|
|
|
QByteArray m_settingsData;
|
|
int m_userId = 0;
|
|
int m_priority = 0;
|
|
int m_exerciseId = 0;
|
|
};
|
|
|
|
class MessageFactory;
|
|
class LTSPROJECTIONWORKSTATION_EXPORT LtsProjectionWorkstation : public QObject, public AbstractMessageHandler
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
static LtsProjectionWorkstation *getInstance();
|
|
static bool hasInstance();
|
|
|
|
const LoginInformation &lastLoginRequest() const { return m_lastLoginRequest; }
|
|
LoginInformation pendingLoginRequest();
|
|
bool hasPendingLoginRequest() const { return !!m_pendingLoginRequest; }
|
|
void setProjectionOperatorPreset(const QString &operatorName, const QString &operatorPassword);
|
|
const QPair<QString, QString> &projectionOperatorPreset() const { return m_projectionOperatorPreset; }
|
|
|
|
|
|
void handleMessage(LtsWebSocket::AbstractClientMessage *message) override final;
|
|
|
|
public slots:
|
|
void slotLoginRequestReceived(int userId, int exerciseId);
|
|
void slotLogoutRequestReceived();
|
|
|
|
void slotLogoffDone();
|
|
|
|
signals:
|
|
void signalLoginRequestReceived(int userId, int exerciseId);
|
|
void signalLogoutRequestReceived();
|
|
|
|
private slots:
|
|
void clientDisconnected(LtsWebSocket::ClientConnection* client);
|
|
void clientConnected(LtsWebSocket::ClientConnection* client);
|
|
|
|
private:
|
|
explicit LtsProjectionWorkstation(QObject *parent = nullptr);
|
|
~LtsProjectionWorkstation();
|
|
static void cleanupLtsProjectionWorkstation();
|
|
|
|
LOGGER_T m_logger;
|
|
MessageFactory *m_messageFactory;
|
|
LtsWebSocket::LtsWebSocketServer *m_webSocketServer;
|
|
|
|
|
|
LoginInformation m_lastLoginRequest;
|
|
|
|
LoginInformation *m_pendingLoginRequest;
|
|
QPair<QString , QString > m_projectionOperatorPreset;
|
|
|
|
QVector<LtsWebSocket::ClientConnection*> m_connections;
|
|
|
|
VncServerManager *m_vncManager;
|
|
};
|
|
|
|
}
|