- Formatted all CodeGen module files (9 files) - Formatted LtsAppDescriptor module files - Formatted LtsAppManager/AppChooser files - Applied clang-format to all DTC and enum headers across modules - Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/) Cosmetic changes only, no functional modifications. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
57 lines
1.7 KiB
C++
57 lines
1.7 KiB
C++
|
|
|
|
#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;
|
|
}
|
|
|
|
} // namespace LtsProjectionWorkstation
|