Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "client_message.h"
|
||||
#include "json_keys.h"
|
||||
#include "message_handler.h"
|
||||
|
||||
namespace LtsProjectionWorkstation
|
||||
{
|
||||
|
||||
//----------------- Message Factory -----------------
|
||||
|
||||
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);
|
||||
}
|
||||
//---------------------------------------------------
|
||||
|
||||
//------------------ Login Request ------------------
|
||||
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;
|
||||
}
|
||||
//---------------------------------------------------
|
||||
|
||||
//------------------ Logout Request -----------------
|
||||
void LogoutRequest::process()
|
||||
{
|
||||
m_client->addReply(m_messageHandler->handleLogoutRequest());
|
||||
}
|
||||
|
||||
bool LogoutRequest::hasValidData() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//---------------------------------------------------
|
||||
|
||||
} // namespace LtsProjectionWorkstation
|
||||
Reference in new issue
Block a user