Continues migration with DDS, Common
This commit is contained in:
1 parent
9b15cee841
commit
fa48db111e
668 files changed
+111841
-2
No files matched your search
@@ -0,0 +1,63 @@
|
||||
|
||||
|
||||
|
||||
#include "client_message.h"
|
||||
#include "json_keys.h"
|
||||
#include "message_handler.h"
|
||||
|
||||
namespace LtsProjectionWorkstation
|
||||
{
|
||||
|
||||
|
||||
|
||||
LtsWebSocket::AbstractClientMessage *ClientMessageFactory::createMessage(LtsWebSocket::ReplyHandler *client, const QString &message)
|
||||
{
|
||||
LtsWebSocket::AbstractClientMessage *result = checkAttributes(client, message);
|
||||
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (m_type == JsonKeys::LOGIN_REQUEST())
|
||||
result = new LoginRequest(m_messageHandler, client, m_type, m_uuid, m_data);
|
||||
|
||||
if (m_type == JsonKeys::LOGOUT_REQUEST())
|
||||
result = new LoginRequest(m_messageHandler, client, m_type, m_uuid, m_data);
|
||||
|
||||
return checkResult(client, message, result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LoginRequest::process()
|
||||
{
|
||||
if (hasValidData())
|
||||
{
|
||||
int userId = m_data.toObject().value(JsonKeys::USER_ID()).toInt(-1),
|
||||
userPriority = m_data.toObject().value(JsonKeys::USER_PRIORITY()).toInt(-1),
|
||||
exerciseId = m_data.toObject().value(JsonKeys::EXERCISE_ID()).toInt(-1);
|
||||
m_client->addReply(m_messageHandler->handleLoginRequest(userId, userPriority, exerciseId));
|
||||
}
|
||||
}
|
||||
|
||||
bool LoginRequest::hasValidData() const
|
||||
{
|
||||
return m_data.isObject()
|
||||
&& m_data.toObject().value(JsonKeys::USER_ID()).toInt(-1) > -1
|
||||
&& m_data.toObject().value(JsonKeys::USER_PRIORITY()).toInt(-1) > -1
|
||||
&& m_data.toObject().value(JsonKeys::EXERCISE_ID()).toInt(-1) > -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LogoutRequest::process()
|
||||
{
|
||||
m_client->addReply(m_messageHandler->handleLogoutRequest());
|
||||
}
|
||||
|
||||
bool LogoutRequest::hasValidData() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWebSocket/client_message_factory.h>
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
|
||||
namespace LtsProjectionWorkstation
|
||||
{
|
||||
class MessageHandler;
|
||||
|
||||
class ClientMessageFactory : public LtsWebSocket::AbstractClientMessageFactory
|
||||
{
|
||||
public:
|
||||
explicit ClientMessageFactory(MessageHandler *messageHandler)
|
||||
: LtsWebSocket::AbstractClientMessageFactory(getLogger("ClientMessageFactory"))
|
||||
, m_messageHandler(messageHandler)
|
||||
{}
|
||||
|
||||
|
||||
LtsWebSocket::AbstractClientMessage *createMessage(LtsWebSocket::ReplyHandler *client, const QString &message) override final;
|
||||
|
||||
private:
|
||||
MessageHandler *m_messageHandler;
|
||||
};
|
||||
|
||||
class ClientMessage : public LtsWebSocket::AbstractClientMessage
|
||||
{
|
||||
public:
|
||||
explicit ClientMessage(MessageHandler *messageHandler, LtsWebSocket::ReplyHandler *client, const QString &type, const QString &uuid, const QJsonValue &data)
|
||||
: AbstractClientMessage(client, type, uuid, data)
|
||||
, m_messageHandler(messageHandler)
|
||||
{}
|
||||
|
||||
protected:
|
||||
MessageHandler *m_messageHandler;
|
||||
|
||||
};
|
||||
|
||||
class LoginRequest : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit LoginRequest(MessageHandler *messageHandler, LtsWebSocket::ReplyHandler *client, const QString &type, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage(messageHandler, client, type, uuid, data)
|
||||
{}
|
||||
|
||||
void process();
|
||||
bool hasValidData() const;
|
||||
};
|
||||
|
||||
class LogoutRequest : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit LogoutRequest(MessageHandler *messageHandler, LtsWebSocket::ReplyHandler *client, const QString &type, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage(messageHandler, client, type, uuid, data)
|
||||
{}
|
||||
|
||||
void process();
|
||||
bool hasValidData() const;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace LtsProjectionWorkstation
|
||||
{
|
||||
namespace JsonKeys
|
||||
{
|
||||
|
||||
inline QString ERROR_MESSAGE() { return QStringLiteral("errorMessage"); }
|
||||
|
||||
|
||||
inline QString LOGIN_REQUEST() { return QStringLiteral("loginRequest"); }
|
||||
inline QString LOGOUT_REQUEST() { return QStringLiteral("logoutRequest"); }
|
||||
inline QString DISCONNECT_REQUEST() { return QStringLiteral("disconnectRequest"); }
|
||||
|
||||
|
||||
|
||||
inline QString LOGIN_REPLY() { return QStringLiteral("loginReply"); }
|
||||
inline QString LOGOUT_REPLY() { return QStringLiteral("logoutReply"); }
|
||||
inline QString DEDICAED_DISCONNECT() { return QStringLiteral("dedicatedDisconnect"); }
|
||||
|
||||
|
||||
inline QString USER_ID() { return QStringLiteral("userId"); }
|
||||
inline QString USER_PRIORITY() { return QStringLiteral("userPriority"); }
|
||||
inline QString EXERCISE_ID() { return QStringLiteral("exerciseId"); }
|
||||
inline QString NAME() { return QStringLiteral("name"); }
|
||||
inline QString PORT() { return QStringLiteral("port"); }
|
||||
inline QString WIDTH() { return QStringLiteral("width"); }
|
||||
inline QString HEIGHT() { return QStringLiteral("height"); }
|
||||
inline QString REASON() { return QStringLiteral("reason"); }
|
||||
inline QString SUCCESS() { return QStringLiteral("success"); }
|
||||
inline QString SCREENS() { return QStringLiteral("screens"); }
|
||||
inline QString SETTINGS_DATA() { return QStringLiteral("settingsData"); }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
#include "message_factory.h"
|
||||
#include "messages.h"
|
||||
#include "json_keys.h"
|
||||
|
||||
#include <LtsWebSocket/client_message.h>
|
||||
#include <LtsWebSocket/json_keys.h>
|
||||
|
||||
#include <QUuid>
|
||||
|
||||
namespace LtsProjectionWorkstation
|
||||
{
|
||||
|
||||
LtsWebSocket::AbstractClientMessage *MessageFactory::createMessage(LtsWebSocket::ReplyHandler *client, const QString &message)
|
||||
{
|
||||
|
||||
|
||||
if (m_uuid.isEmpty())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Got message without uuid: " << message << "'";
|
||||
WARNING_LOG(m_logger) << "Created UUID for error message!";
|
||||
return new ErrorMessage(QUuid::createUuid().toString(), QStringLiteral("Got message without uuid"));
|
||||
}
|
||||
|
||||
LtsWebSocket::AbstractClientMessage *result = checkAttributes(client, message);
|
||||
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (m_type == JsonKeys::DEDICAED_DISCONNECT())
|
||||
result = new STC::DedicatedDisconnect(m_handler, client, m_type, m_uuid, m_data);
|
||||
|
||||
if (m_type == JsonKeys::LOGIN_REPLY())
|
||||
result = new STC::LoginRequestReply(m_handler, client, m_type, m_uuid, m_data);
|
||||
|
||||
if (m_type == JsonKeys::LOGOUT_REPLY())
|
||||
result = new STC::LoginRequestReply(m_handler, client, m_type, m_uuid, m_data);
|
||||
|
||||
if (m_type == JsonKeys::LOGIN_REQUEST())
|
||||
result = new CTS::LoginRequest(m_handler, client, m_type, m_uuid, m_data);
|
||||
|
||||
if (m_type == JsonKeys::LOGOUT_REQUEST())
|
||||
result = new CTS::LogoutRequest(m_handler, client, m_type, m_uuid, m_data);
|
||||
|
||||
if (m_type == JsonKeys::DISCONNECT_REQUEST())
|
||||
result = new CTS::DisconnectRequest(m_handler, client, m_type, m_uuid, m_data);
|
||||
|
||||
if (m_type == LtsWebSocket::JsonKeys::ERROR_())
|
||||
return nullptr;
|
||||
|
||||
return checkResult(client, message, result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <LtsWebSocket/client_message_factory.h>
|
||||
#include <LtsProjectionWorkstation/logger.h>
|
||||
|
||||
#include <LtsProjectionWorkstation/lts_projection_workstation_export.h>
|
||||
|
||||
namespace LtsProjectionWorkstation
|
||||
{
|
||||
|
||||
class AbstractMessageHandler;
|
||||
|
||||
class LTSPROJECTIONWORKSTATION_EXPORT MessageFactory
|
||||
: public LtsWebSocket::AbstractClientMessageFactory
|
||||
{
|
||||
|
||||
public:
|
||||
MessageFactory(AbstractMessageHandler *handler, LOGGER_T &logger)
|
||||
: LtsWebSocket::AbstractClientMessageFactory(logger)
|
||||
, m_handler(handler)
|
||||
{}
|
||||
|
||||
|
||||
LtsWebSocket::AbstractClientMessage *createMessage(LtsWebSocket::ReplyHandler *client, const QString &message) override final;
|
||||
|
||||
private:
|
||||
AbstractMessageHandler *m_handler;
|
||||
};
|
||||
|
||||
}
|
||||
+210
@@ -0,0 +1,210 @@
|
||||
|
||||
|
||||
|
||||
#include "messages.h"
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QDebug>
|
||||
|
||||
namespace LtsProjectionWorkstation
|
||||
{
|
||||
|
||||
|
||||
STC::LoginRequestReply::LoginRequestReply(const QString &uuid, Reason reason, int reasonUserId, const QVector<VncScreen> &screens)
|
||||
: Message(nullptr, nullptr, JsonKeys::LOGIN_REPLY(), uuid, QJsonValue())
|
||||
, m_screens(screens)
|
||||
, m_reasonUserId(reasonUserId)
|
||||
, m_reason(reason)
|
||||
{
|
||||
QJsonObject result;
|
||||
QJsonArray arr;
|
||||
for (const VncScreen &vncScreen : screens)
|
||||
{
|
||||
QJsonObject screen;
|
||||
screen.insert(JsonKeys::NAME(), vncScreen.name);
|
||||
screen.insert(JsonKeys::PORT(), vncScreen.port);
|
||||
screen.insert(JsonKeys::WIDTH(), vncScreen.geometry.width());
|
||||
screen.insert(JsonKeys::HEIGHT(), vncScreen.geometry.height());
|
||||
arr.append(screen);
|
||||
}
|
||||
result.insert(JsonKeys::REASON(), reason);
|
||||
result.insert(JsonKeys::USER_ID(), reasonUserId);
|
||||
result.insert(JsonKeys::SCREENS(), arr);
|
||||
m_replyData = QJsonValue(result);
|
||||
}
|
||||
|
||||
|
||||
void STC::LoginRequestReply::process()
|
||||
{
|
||||
if (!m_handler || !m_client) return;
|
||||
QJsonObject dataObj = m_data.toObject();
|
||||
m_reason = Reason(dataObj.value(JsonKeys::REASON()).toInt());
|
||||
m_reasonUserId = dataObj.value(JsonKeys::USER_ID()).toInt();
|
||||
const auto arr = dataObj.value(JsonKeys::SCREENS()).toArray();
|
||||
for (const QJsonValue &val : arr)
|
||||
{
|
||||
const QJsonObject obj(val.toObject());
|
||||
VncScreen screen;
|
||||
screen.name = obj.value(JsonKeys::NAME()).toString(QStringLiteral("err"));
|
||||
screen.port = obj.value(JsonKeys::PORT()).toInt(-1);
|
||||
screen.geometry = QRect(0, 0,
|
||||
obj.value(JsonKeys::WIDTH()).toInt(-1),
|
||||
obj.value(JsonKeys::HEIGHT()).toInt(-1));
|
||||
m_screens.append(std::move(screen));
|
||||
}
|
||||
m_handler->handleMessage(this);
|
||||
}
|
||||
|
||||
|
||||
bool STC::LoginRequestReply::hasValidData() const
|
||||
{
|
||||
if (!m_handler || !m_client) return false;
|
||||
QJsonObject obj = m_data.toObject();
|
||||
if (obj.value(JsonKeys::REASON()).isUndefined()) return false;
|
||||
if (obj.value(JsonKeys::USER_ID()).isUndefined()) return false;
|
||||
if (obj.value(JsonKeys::SCREENS()).isUndefined()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
STC::DedicatedDisconnect::DedicatedDisconnect(const QString &uuid, int userId)
|
||||
: Message(nullptr, nullptr, JsonKeys::DEDICAED_DISCONNECT(), uuid, QJsonValue())
|
||||
, m_userId(userId)
|
||||
{
|
||||
QJsonObject result;
|
||||
result.insert(JsonKeys::USER_ID(), m_userId);
|
||||
m_replyData = result;
|
||||
}
|
||||
|
||||
|
||||
void STC::DedicatedDisconnect::process()
|
||||
{
|
||||
if (!m_handler || !m_client) return;
|
||||
QJsonObject obj = m_data.toObject();
|
||||
m_userId = obj.value(JsonKeys::USER_ID()).toInt(-1);
|
||||
m_handler->handleMessage(this);
|
||||
}
|
||||
|
||||
|
||||
bool STC::DedicatedDisconnect::hasValidData() const
|
||||
{
|
||||
if (!m_handler || !m_client) return false;
|
||||
QJsonObject obj = m_data.toObject();
|
||||
if (obj.value(JsonKeys::USER_ID()).isUndefined()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CTS::LoginRequest::LoginRequest(const QString &uuid, int userId, int priority, int exerciseId, const QByteArray &settingsData)
|
||||
: Message(nullptr, nullptr, JsonKeys::LOGIN_REQUEST(), uuid, QJsonValue())
|
||||
, m_settingsData(settingsData), m_userId(userId), m_priority(priority), m_exerciseId(exerciseId)
|
||||
{
|
||||
QJsonObject result;
|
||||
result.insert(JsonKeys::USER_ID(), m_userId);
|
||||
result.insert(JsonKeys::USER_PRIORITY(), m_priority);
|
||||
result.insert(JsonKeys::EXERCISE_ID(), m_exerciseId);
|
||||
result.insert(JsonKeys::SETTINGS_DATA(), QString::fromLatin1(m_settingsData.toBase64()));
|
||||
m_replyData = result;
|
||||
}
|
||||
|
||||
|
||||
void CTS::LoginRequest::process()
|
||||
{
|
||||
if (!m_handler || !m_client) return;
|
||||
QJsonObject obj = m_data.toObject();
|
||||
m_userId = obj.value(JsonKeys::USER_ID()).toInt(-1);
|
||||
m_priority = obj.value(JsonKeys::USER_PRIORITY()).toInt(-1);
|
||||
m_exerciseId = obj.value(JsonKeys::EXERCISE_ID()).toInt(-1);
|
||||
m_settingsData = QByteArray::fromBase64(obj.value(JsonKeys::SETTINGS_DATA()).toString().toLatin1());
|
||||
m_handler->handleMessage(this);
|
||||
}
|
||||
|
||||
|
||||
bool CTS::LoginRequest::hasValidData() const
|
||||
{
|
||||
if (!m_handler || !m_client) return false;
|
||||
QJsonObject obj = m_data.toObject();
|
||||
if (obj.value(JsonKeys::USER_ID()).isUndefined()) return false;
|
||||
if (obj.value(JsonKeys::EXERCISE_ID()).isUndefined()) return false;
|
||||
if (obj.value(JsonKeys::USER_PRIORITY()).isUndefined()) return false;
|
||||
if (obj.value(JsonKeys::SETTINGS_DATA()).isUndefined()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CTS::LogoutRequest::process()
|
||||
{
|
||||
if (!m_handler || !m_client) return;
|
||||
m_handler->handleMessage(this);
|
||||
}
|
||||
|
||||
|
||||
bool CTS::LogoutRequest::hasValidData() const
|
||||
{
|
||||
if (!m_handler || !m_client) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CTS::DisconnectRequest::DisconnectRequest(const QString &uuid, int userId)
|
||||
: Message(nullptr, nullptr, JsonKeys::DISCONNECT_REQUEST(), uuid, QJsonValue())
|
||||
, m_userId(userId)
|
||||
{
|
||||
qDebug() << " 1 m_userId = " << m_userId;
|
||||
QJsonObject result;
|
||||
result.insert(JsonKeys::USER_ID(), m_userId);
|
||||
m_replyData = result;
|
||||
}
|
||||
|
||||
void CTS::DisconnectRequest::process()
|
||||
{
|
||||
if (!m_handler || !m_client) return;
|
||||
QJsonObject obj = m_data.toObject();
|
||||
m_userId = obj.value(JsonKeys::USER_ID()).toInt(-1);
|
||||
qDebug() << " 2 m_userId = " << m_userId;
|
||||
m_handler->handleMessage(this);
|
||||
}
|
||||
|
||||
bool CTS::DisconnectRequest::hasValidData() const
|
||||
{
|
||||
if (!m_handler || !m_client) return false;
|
||||
QJsonObject obj = m_data.toObject();
|
||||
if (obj.value(JsonKeys::USER_ID()).isUndefined()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ErrorMessage::ErrorMessage(const QString &uuid, const QString &reason)
|
||||
: Message(nullptr, nullptr, JsonKeys::ERROR_MESSAGE(), uuid, QJsonValue())
|
||||
, m_reason(reason)
|
||||
{
|
||||
QJsonObject result;
|
||||
result.insert(JsonKeys::REASON(), m_reason);
|
||||
m_replyData = result;
|
||||
}
|
||||
|
||||
|
||||
void ErrorMessage::process()
|
||||
{
|
||||
if (!m_handler || !m_client) return;
|
||||
QJsonObject obj = m_data.toObject();
|
||||
m_reason = obj.value(JsonKeys::REASON()).toString(QStringLiteral("err"));
|
||||
m_handler->handleMessage(this);
|
||||
}
|
||||
|
||||
|
||||
bool ErrorMessage::hasValidData() const
|
||||
{
|
||||
if (!m_handler || !m_client) return false;
|
||||
QJsonObject obj = m_data.toObject();
|
||||
if (obj.value(JsonKeys::REASON()).isUndefined()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+192
@@ -0,0 +1,192 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "json_keys.h"
|
||||
|
||||
#include <LtsWebSocket/json_keys.h>
|
||||
#include <LtsWebSocket/client_message.h>
|
||||
|
||||
#include <LtsProjectionWorkstation/lts_projection_workstation_export.h>
|
||||
#include <LtsProjectionWorkstation/vnc_server_manager.h>
|
||||
|
||||
#include <QVector>
|
||||
|
||||
namespace LtsWebSocket { class ReplyHandler; }
|
||||
|
||||
namespace LtsProjectionWorkstation
|
||||
{
|
||||
|
||||
class AbstractMessageHandler
|
||||
{
|
||||
public:
|
||||
virtual ~AbstractMessageHandler() = default;
|
||||
virtual void handleMessage(LtsWebSocket::AbstractClientMessage *message) = 0;
|
||||
};
|
||||
|
||||
|
||||
class Reply : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
Reply(const QString &type, const int typeId, const QString &uuid, const QJsonObject &data)
|
||||
: LtsWebSocket::ReplyMessage(type, typeId, uuid)
|
||||
{
|
||||
m_jsonRepresentation.insert(LtsWebSocket::JsonKeys::DATA(), data);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Message : public LtsWebSocket::AbstractClientMessage
|
||||
{
|
||||
public:
|
||||
Message(AbstractMessageHandler *handler, LtsWebSocket::ReplyHandler *client, const QString &type, const QString &uuid, const QJsonValue &data = QJsonValue())
|
||||
: LtsWebSocket::AbstractClientMessage(client, type, 1, uuid, data)
|
||||
, m_handler(handler)
|
||||
{}
|
||||
|
||||
LtsWebSocket::ReplyMessage *toReplyMessage() const
|
||||
{
|
||||
if (!m_handler || !m_client)
|
||||
return new Reply(m_type, m_typeId, m_uuid, m_replyData.toObject());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void addReply(LtsWebSocket::ReplyMessage *reply)
|
||||
{
|
||||
if (m_client)
|
||||
m_client->addReply(reply);
|
||||
}
|
||||
|
||||
protected:
|
||||
AbstractMessageHandler *m_handler;
|
||||
QJsonValue m_replyData;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class LTSPROJECTIONWORKSTATION_EXPORT ErrorMessage : public Message
|
||||
{
|
||||
public:
|
||||
using Message::Message;
|
||||
ErrorMessage(const QString &uuid, const QString &reason);
|
||||
|
||||
|
||||
void process() override final;
|
||||
bool hasValidData() const override final;
|
||||
|
||||
private:
|
||||
QString m_reason;
|
||||
};
|
||||
|
||||
namespace STC
|
||||
{
|
||||
|
||||
class LTSPROJECTIONWORKSTATION_EXPORT LoginRequestReply : public Message
|
||||
{
|
||||
public:
|
||||
enum Reason
|
||||
{
|
||||
LoginSuccessful,
|
||||
OtherUser,
|
||||
};
|
||||
|
||||
using Message::Message;
|
||||
LoginRequestReply(const QString &uuid, Reason reason, int reasonUserId, const QVector<VncScreen> &screens);
|
||||
|
||||
|
||||
void process() override final;
|
||||
bool hasValidData() const override final;
|
||||
|
||||
int reasonUserId() const { return m_reasonUserId; }
|
||||
Reason reason() const { return m_reason; }
|
||||
const QVector<VncScreen> &screens() const { return m_screens; }
|
||||
|
||||
private:
|
||||
QVector<VncScreen> m_screens;
|
||||
int m_reasonUserId = -1;
|
||||
Reason m_reason = LoginSuccessful;
|
||||
};
|
||||
|
||||
class LTSPROJECTIONWORKSTATION_EXPORT DedicatedDisconnect : public Message
|
||||
{
|
||||
public:
|
||||
using Message::Message;
|
||||
DedicatedDisconnect(const QString &uuid, int userId);
|
||||
|
||||
|
||||
void process() override final;
|
||||
bool hasValidData() const override final;
|
||||
|
||||
int userid() const { return m_userId; }
|
||||
|
||||
private:
|
||||
int m_userId = -1;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
namespace CTS
|
||||
{
|
||||
|
||||
class LTSPROJECTIONWORKSTATION_EXPORT LoginRequest : public Message
|
||||
{
|
||||
public:
|
||||
using Message::Message;
|
||||
LoginRequest(const QString &uuid, int userId, int priority, int exerciseId, const QByteArray &settingsData);
|
||||
|
||||
|
||||
void process() override final;
|
||||
bool hasValidData() const override final;
|
||||
|
||||
int userId() const { return m_userId; }
|
||||
int priority() const { return m_priority; }
|
||||
int exerciseId() const { return m_exerciseId; }
|
||||
const QByteArray &settingsData() const { return m_settingsData; }
|
||||
|
||||
private:
|
||||
QByteArray m_settingsData;
|
||||
int m_userId = 0;
|
||||
int m_priority = 0;
|
||||
int m_exerciseId = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class LTSPROJECTIONWORKSTATION_EXPORT LogoutRequest : public Message
|
||||
{
|
||||
public:
|
||||
using Message::Message;
|
||||
explicit LogoutRequest(const QString &uuid)
|
||||
: Message(nullptr, nullptr, JsonKeys::LOGOUT_REQUEST(), uuid, QJsonValue())
|
||||
{}
|
||||
|
||||
|
||||
void process() override final;
|
||||
bool hasValidData() const override final;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class LTSPROJECTIONWORKSTATION_EXPORT DisconnectRequest : public Message
|
||||
{
|
||||
public:
|
||||
using Message::Message;
|
||||
explicit DisconnectRequest(const QString &uuid, int userId);
|
||||
|
||||
|
||||
void process() override final;
|
||||
bool hasValidData() const override final;
|
||||
|
||||
int userId() const { return m_userId; }
|
||||
private:
|
||||
int m_userId{0};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
|
||||
|
||||
#include "reply_message.h"
|
||||
|
||||
namespace LtsProjectionWorkstation
|
||||
{
|
||||
|
||||
LoginReply::LoginReply(const QJsonObject &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage(JsonKeys::LOGIN_REPLY(), uuid)
|
||||
{
|
||||
m_jsonRepresentation.insert(LtsWebSocket::JsonKeys::DATA(), data);
|
||||
}
|
||||
|
||||
LogoutReply::LogoutReply(const QJsonObject &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage(JsonKeys::LOGOUT_REPLY(), uuid)
|
||||
{
|
||||
m_jsonRepresentation.insert(LtsWebSocket::JsonKeys::DATA(), data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
|
||||
|
||||
|
||||
#include "json_keys.h"
|
||||
|
||||
#include <LtsWebSocket/reply_message.h>
|
||||
#include <LtsWebSocket/json_keys.h>
|
||||
|
||||
namespace LtsProjectionWorkstation
|
||||
{
|
||||
|
||||
class LoginReply : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit LoginReply(const QJsonObject &data, const QString &uuid);
|
||||
};
|
||||
|
||||
class LogoutReply : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit LogoutReply(const QJsonObject &data, const QString &uuid);
|
||||
};
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user