54 lines
1.6 KiB
C++
Executable File
54 lines
1.6 KiB
C++
Executable File
#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);
|
|
}
|
|
|
|
}
|