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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user