Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+129
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ClientMessage class is an abstract base class for concrete ClientMessage objects
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#include "client_message.h"
|
||||
|
||||
#include "WebSocketInterface/Messages/reply_message.h"
|
||||
#include "WebSocketInterface/json_keys.h"
|
||||
#include "WebSocketInterface/data_manager.h"
|
||||
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtCore/QUuid>
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
namespace Messages
|
||||
{
|
||||
using namespace JsonKeys;
|
||||
|
||||
// ####### ClientMessageFactory begin #######
|
||||
ClientMessageFactory::ClientMessageFactory(DataManager *dataManager)
|
||||
: LtsWebSocket::AbstractClientMessageFactory(getLogger("ClientMessageFactory"))
|
||||
, m_dataManager(dataManager)
|
||||
{}
|
||||
|
||||
LtsWebSocket::AbstractClientMessage *ClientMessageFactory::createMessage(LtsWebSocket::ReplyHandler *client,
|
||||
const QString &message)
|
||||
{
|
||||
LtsWebSocket::AbstractClientMessage *result = checkAttributes(client, message);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (m_type == OcBaseDownload::WebSocketInterface::JsonKeys::BASE_DL_REQUEST())
|
||||
result = new BaseDlRequest(m_dataManager, client, m_type, m_typeId, m_uuid); // Todo: Check whether typeId is correct
|
||||
|
||||
if (m_type == ParticipantManagement::WebSocketInterface::JsonKeys::OC_POSITION_DATA()) // Todo: Check whether typeId is correct
|
||||
result = new OcPositionRequest(m_dataManager, client, m_type, m_typeId, m_uuid, QJsonDocument::fromJson(message.toUtf8()).object().value(QStringLiteral("data")).toObject() );
|
||||
|
||||
/********************************************************
|
||||
* Warning: 6006 has been negotiated with ESG for ADLER *
|
||||
********************************************************/
|
||||
if (m_type == ParticipantManagement::WebSocketInterface::JsonKeys::PARTY_BASE_DATA())
|
||||
result = new PartyRequest(m_dataManager, client, m_type, 6006, m_uuid); // Todo: Check whether typeId is correct
|
||||
|
||||
return checkResult(client, message, result);
|
||||
}
|
||||
// ####### ClientMessageFactory end #######
|
||||
|
||||
// ####### ClientMessage begin #######
|
||||
ClientMessage::ClientMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonObject &data)
|
||||
: LtsWebSocket::AbstractClientMessage(client, type, typeId, uuid, data)
|
||||
, m_dataManager(dataManager)
|
||||
{}
|
||||
// ####### ClientMessage end #######
|
||||
|
||||
// ####### PartyRequest begin #######
|
||||
PartyRequest::PartyRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid)
|
||||
{}
|
||||
|
||||
void PartyRequest::process()
|
||||
{
|
||||
m_client->addReply(m_dataManager->partyBaseData(m_uuid));
|
||||
}
|
||||
|
||||
bool PartyRequest::hasValidData() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ####### BaseDlRequest begin #######
|
||||
BaseDlRequest::BaseDlRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid)
|
||||
{}
|
||||
|
||||
void BaseDlRequest::process()
|
||||
{
|
||||
if (m_dataManager->exerciseId() == 0) // equipment type, type and participant template only in ex_0
|
||||
{
|
||||
m_client->addReply(m_dataManager->equipmentTypeBaseData(m_uuid));
|
||||
m_client->addReply(m_dataManager->typeBaseData(m_uuid));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_client->addReply(m_dataManager->partyBaseData(m_uuid));
|
||||
m_client->addReply(m_dataManager->participantBaseData(m_uuid));
|
||||
}
|
||||
}
|
||||
|
||||
bool BaseDlRequest::hasValidData() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
OcPositionRequest::OcPositionRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonObject &data)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid, data )
|
||||
{
|
||||
const auto val = data.value(EQUIPMENT_NR());
|
||||
if (val.toInt() > 0)
|
||||
m_equipmentNr = val.toInt();
|
||||
|
||||
}
|
||||
|
||||
void OcPositionRequest::process()
|
||||
{
|
||||
if (m_dataManager->exerciseId() != 0) // equipment type, type and participant template only in ex_0
|
||||
{
|
||||
m_client->addReply(m_dataManager->ocPositionData(m_equipmentNr, m_uuid));
|
||||
}
|
||||
}
|
||||
|
||||
bool OcPositionRequest::hasValidData() const
|
||||
{
|
||||
return m_equipmentNr > 0;
|
||||
}
|
||||
|
||||
// ####### BaseDlRequest end #######
|
||||
|
||||
} // namespace Messages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace ParticipantManagement
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ClientMessage class is an abstract base class for concrete ClientMessage objects
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QJsonObject>
|
||||
|
||||
#include <LtsWebSocket/client_message_factory.h>
|
||||
#include <LtsWebSocket/client_message.h>
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
class DataManager;
|
||||
|
||||
namespace Messages
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief The ClientMessageFactory class creates ClientMessages which will then be processed
|
||||
*/
|
||||
class ClientMessageFactory final : public LtsWebSocket::AbstractClientMessageFactory
|
||||
{
|
||||
public:
|
||||
explicit ClientMessageFactory(DataManager *dataManager);
|
||||
|
||||
/**
|
||||
* @brief create Only way to create a ClientMessage object
|
||||
* @param message Text message which will be converted to a ClientMessage object
|
||||
* @return A ClientMessage object, which represents a concrete ClientMessage
|
||||
*/
|
||||
LtsWebSocket::AbstractClientMessage *createMessage(LtsWebSocket::ReplyHandler *client,
|
||||
const QString &message);
|
||||
|
||||
private:
|
||||
DataManager *m_dataManager;
|
||||
|
||||
}; // class ClientMessageFactory
|
||||
|
||||
/**
|
||||
* @brief The ClientMessage class is an abstract base class for concrete ClientMessage objects
|
||||
*/
|
||||
class ClientMessage : public LtsWebSocket::AbstractClientMessage
|
||||
{
|
||||
protected: // method
|
||||
explicit ClientMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonObject &data = QJsonObject());
|
||||
|
||||
protected: // attributes
|
||||
DataManager *m_dataManager;
|
||||
}; // class ClientMessage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief The PartyRequest class handles the party DL request and sends multiple all party data for the exercise
|
||||
*/
|
||||
class PartyRequest : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit PartyRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid);
|
||||
|
||||
void process();
|
||||
bool hasValidData() const;
|
||||
}; // class BaseDlRequest
|
||||
|
||||
/**
|
||||
* @brief The BaseDlRequest class handles the base DL request and sends multiple replys depending on the data requested
|
||||
*/
|
||||
class BaseDlRequest : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit BaseDlRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid);
|
||||
|
||||
void process();
|
||||
bool hasValidData() const;
|
||||
}; // class BaseDlRequest
|
||||
/**
|
||||
* @brief The BaseDlRequest class handles the base DL request and sends multiple replys depending on the data requested
|
||||
*/
|
||||
class OcPositionRequest : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit OcPositionRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonObject &data);
|
||||
|
||||
void process();
|
||||
bool hasValidData() const;
|
||||
private:
|
||||
int m_equipmentNr = 0;
|
||||
|
||||
}; // class BaseDlRequest
|
||||
|
||||
} // namespace Messages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace ParticipantManagement
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ReplyMessage class is an abstract base class for all possible messages which are sent to the client
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#include "reply_message.h"
|
||||
|
||||
#include <LtsWebSocket/json_keys.h>
|
||||
#include "WebSocketInterface/json_keys.h"
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
namespace Messages
|
||||
{
|
||||
using namespace JsonKeys;
|
||||
using namespace LtsWebSocket::JsonKeys;
|
||||
|
||||
// ####### EquipmentTypeBaseData begin #######
|
||||
EquipmentTypeBaseData::EquipmentTypeBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (EQUIPMENT_TYPE_BASE_DATA(), 1, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### EquipmentTypeBaseData end #######
|
||||
|
||||
// ####### TypeBaseData begin #######
|
||||
TypeBaseData::TypeBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (TYPE_BASE_DATA(), 2, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### TypeBaseData end #######
|
||||
|
||||
// ####### PartyBaseData begin #######
|
||||
/********************************************************
|
||||
* Warning: 6006 has been negotiated with ESG for ADLER *
|
||||
********************************************************/
|
||||
PartyBaseData::PartyBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (PARTY_BASE_DATA(), 6006, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### PartyBaseData end #######
|
||||
|
||||
// ####### ParticipantBaseData begin #######
|
||||
ParticipantBaseData::ParticipantBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (PARTICIPANT_BASE_DATA(), 4, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
|
||||
OcPositionData::OcPositionData(const QJsonObject &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (OC_POSITION_DATA(), 5, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
|
||||
// ####### ParticipantBaseData end #######
|
||||
|
||||
} // namespace Messages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace ParticipantManagement
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ReplyMessage class is an abstract base class for all possible messages which are sent to the client
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <LtsWebSocket/reply_message.h>
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QString>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
namespace Messages
|
||||
{
|
||||
/**
|
||||
* @brief The EquipmentTypeBaseData class equipment type data for base DL
|
||||
*/
|
||||
class EquipmentTypeBaseData : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit EquipmentTypeBaseData(const QJsonArray &data, const QString &uuid);
|
||||
}; // class EquipmentTypeBaseData
|
||||
|
||||
/**
|
||||
* @brief The TypeBaseData class type data for base DL
|
||||
*/
|
||||
class TypeBaseData : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit TypeBaseData(const QJsonArray &data, const QString &uuid);
|
||||
}; // class TypeBaseData
|
||||
|
||||
/**
|
||||
* @brief The ParticipantTemplateBaseData class participant template data for base DL
|
||||
*/
|
||||
class ParticipantTemplateBaseData : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit ParticipantTemplateBaseData(const QJsonArray &data, const QString &uuid);
|
||||
}; // class ParticipantTemplateBaseData
|
||||
|
||||
/**
|
||||
* @brief The PartyBaseData class party data for base DL
|
||||
*/
|
||||
class PartyBaseData : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit PartyBaseData(const QJsonArray &data, const QString &uuid);
|
||||
}; // class PartyBaseData
|
||||
|
||||
/**
|
||||
* @brief The ParticipantOrganisationBaseData class participant organisation data for base DL
|
||||
*/
|
||||
class ParticipantOrganisationBaseData : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit ParticipantOrganisationBaseData(const QJsonArray &data, const QString &uuid);
|
||||
}; // class ParticipantOrganisationBaseData
|
||||
|
||||
/**
|
||||
* @brief The ParticipantBaseData class participant data for base DL
|
||||
*/
|
||||
class ParticipantBaseData : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit ParticipantBaseData(const QJsonArray &data, const QString &uuid);
|
||||
}; // class ParticipantBaseData
|
||||
|
||||
/**
|
||||
* @brief The ParticipantBaseData class participant data for base DL
|
||||
*/
|
||||
class OcPositionData : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit OcPositionData(const QJsonObject &data, const QString &uuid);
|
||||
}; // class ParticipantBaseData
|
||||
|
||||
|
||||
} // namespace Messages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace ParticipantManagement
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The DataManager class takes strucure element data from the HandlerStructureElement,
|
||||
* offers an interface to get and set structure data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#include "data_manager.h"
|
||||
#include "Messages/reply_message.h"
|
||||
#include "main_handler.h"
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
DataManager::DataManager(int exerciseId, const std::shared_ptr<DatabaseInterface> &dbInterface, const std::shared_ptr<ParticipantManagement::Interface::Dtc> &dtc)
|
||||
: LtsWebSocket::DataManagerBaseDl<DatabaseInterface>(dbInterface, getLogger(QStringLiteral("DataManager")))
|
||||
, m_exerciseId(exerciseId)
|
||||
, m_ppmDtc(dtc)
|
||||
{}
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
|
||||
LtsWebSocket::ReplyMessage *DataManager::equipmentTypeBaseData(const QString &uuid) const
|
||||
{
|
||||
return toBaseDataMessageFromDb<Database::PpmEquipmentType, Messages::EquipmentTypeBaseData>(uuid);
|
||||
}
|
||||
|
||||
LtsWebSocket::ReplyMessage *DataManager::typeBaseData(const QString &uuid) const
|
||||
{
|
||||
return toBaseDataMessageFromDb<Database::PpmType, Messages::TypeBaseData>(uuid);
|
||||
}
|
||||
|
||||
LtsWebSocket::ReplyMessage *DataManager::partyBaseData(const QString &uuid) const
|
||||
{
|
||||
return toBaseDataMessageFromDb<Database::PpmParty, Messages::PartyBaseData>(uuid);
|
||||
}
|
||||
|
||||
LtsWebSocket::ReplyMessage *DataManager::participantBaseData(const QString &uuid) const
|
||||
{
|
||||
return toBaseDataMessageFromDb<Database::PpmParticipant, Messages::ParticipantBaseData>(uuid);
|
||||
}
|
||||
|
||||
LtsWebSocket::ReplyMessage *DataManager::ocPositionData(int equipmentNr, const QString &uuid) const
|
||||
{
|
||||
if (!m_ppmDtc->isParticipantPositionEnabled() || !m_ppmDtc->isParticipantEnabled())
|
||||
{
|
||||
m_ppmDtc->enableParticipantPosition();
|
||||
m_ppmDtc->enableParticipant();
|
||||
}
|
||||
ParticipantPosition pos = m_ppmDtc->participantPosition(m_ppmDtc->participantIdByEquipmentNumber(equipmentNr));
|
||||
QJsonObject obj;
|
||||
obj[QStringLiteral("participantId")] = pos.participantId();
|
||||
obj[QStringLiteral("lat")] = pos.pos().lat();
|
||||
obj[QStringLiteral("lon")] = pos.pos().lon();
|
||||
obj[QStringLiteral("height")] = pos.pos().z();
|
||||
obj[QStringLiteral("roomId")] = pos.roomId();
|
||||
obj[QStringLiteral("buildingId")] = pos.buildingId();
|
||||
|
||||
return new ParticipantManagement::WebSocketInterface::Messages::OcPositionData(obj, uuid);
|
||||
}
|
||||
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace ParticipantManagement
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The DataManager class is a convenience class for managing structure data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <LtsWebSocket/data_manager_base_dl.h>
|
||||
#include <ParticipantManagement/ppm_db.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include "logger.h"
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
class MainHandler;
|
||||
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief The DataManager class is a convenience class for managing structure data
|
||||
*/
|
||||
class DataManager final : public LtsWebSocket::DataManagerBaseDl<DatabaseInterface>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief DataManager Constructor
|
||||
* @param mainHandler Source for needed handlers
|
||||
*/
|
||||
explicit DataManager(int exerciseId,
|
||||
const std::shared_ptr<DatabaseInterface> &dbInterface,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &dtc);
|
||||
|
||||
int exerciseId() const { return m_exerciseId; }
|
||||
|
||||
LtsWebSocket::ReplyMessage *equipmentTypeBaseData(const QString &uuid) const;
|
||||
LtsWebSocket::ReplyMessage *typeBaseData(const QString &uuid) const;
|
||||
LtsWebSocket::ReplyMessage *partyBaseData(const QString &uuid) const;
|
||||
LtsWebSocket::ReplyMessage *participantBaseData(const QString &uuid) const;
|
||||
LtsWebSocket::ReplyMessage *ocPositionData(int equipmentNr, const QString &uuid) const;
|
||||
|
||||
private:
|
||||
int m_exerciseId;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
}; // class DataManager
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace ParticipantManagement
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Header file which holds all occuring JSON keys
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <OcBaseDownload/WebSocketInterface/json_keys.h>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
/**
|
||||
* @brief Namespace which holds all occuring JSON keys as const QString objects
|
||||
*/
|
||||
namespace JsonKeys
|
||||
{
|
||||
// types for client --> server messages
|
||||
inline QString EQUIPMENT_NR() { return QStringLiteral("equipmentNr"); }
|
||||
// types for server --> client messages
|
||||
inline QString EQUIPMENT_TYPE_BASE_DATA() { return QStringLiteral("equipmentTypeBaseData"); }
|
||||
inline QString TYPE_BASE_DATA() { return QStringLiteral("typeBaseData"); }
|
||||
inline QString PARTY_BASE_DATA() { return QStringLiteral("partyBaseData"); }
|
||||
inline QString PARTICIPANT_BASE_DATA() { return QStringLiteral("participantBaseData"); }
|
||||
inline QString OC_POSITION_DATA() { return QStringLiteral("ocPositionData"); }
|
||||
|
||||
} // namespace JsonKeys
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace ParticipantManagement
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Handler for the WebSocket Interface
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#include "websocket_interface_handler.h"
|
||||
|
||||
#include "main_handler.h"
|
||||
#include "data_manager.h"
|
||||
#include "WebSocketInterface/Messages/client_message.h"
|
||||
#include "settings.h"
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
|
||||
WebSocketInterfaceHandler::WebSocketInterfaceHandler(MainHandler *mainHandler, QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_webSocketServer(nullptr)
|
||||
, m_messageFactory(nullptr)
|
||||
, m_dataManager(nullptr)
|
||||
, m_mainHandler(mainHandler)
|
||||
, m_logger(getLogger("WebSocketInterfaceHandler"))
|
||||
{
|
||||
}
|
||||
|
||||
WebSocketInterfaceHandler::~WebSocketInterfaceHandler()
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
|
||||
bool WebSocketInterfaceHandler::init()
|
||||
{
|
||||
cleanup();
|
||||
|
||||
DEBUG_LOG(m_logger) << "... ok";
|
||||
|
||||
m_dataManager = new DataManager(m_mainHandler->exerciseId(), m_mainHandler->db(), m_mainHandler->ddsHandler()->dtc());
|
||||
|
||||
m_messageFactory = new Messages::ClientMessageFactory(m_dataManager);
|
||||
|
||||
m_webSocketServer = new LtsWebSocket::LtsWebSocketServer(m_messageFactory, this);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Initialising LtsWebSocketServer";
|
||||
if (!m_webSocketServer->init(QStringLiteral("PPM"), Settings::getWebSocketServerPortRange(1)))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Failed to initialise LtsWebSocketServer";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "... ok";
|
||||
|
||||
DEBUG_LOG(m_logger) << "Connection signals and slots";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void WebSocketInterfaceHandler::cleanup()
|
||||
{
|
||||
delete m_webSocketServer;
|
||||
delete m_messageFactory;
|
||||
delete m_dataManager;
|
||||
}
|
||||
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace ParticipantManagement
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Handler for the WebSocket Interface
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
#include <LtsWebSocket/lts_web_socket_server.h>
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
class MainHandler;
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
namespace Messages
|
||||
{
|
||||
class ClientMessageFactory;
|
||||
}
|
||||
class DataManager;
|
||||
|
||||
/**
|
||||
* @brief The WebSocketInterfaceHandler class is the main class for the WebSocketInterface
|
||||
*/
|
||||
class WebSocketInterfaceHandler final : public QObject
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief WebSocketInterfaceHandler Constructor
|
||||
* @param mainHandler MainHandler to get the HandlerStructureElement from
|
||||
*/
|
||||
explicit WebSocketInterfaceHandler(MainHandler *mainHandler, QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief ~WebSocketInterfaceHandler Destructor
|
||||
*/
|
||||
~WebSocketInterfaceHandler();
|
||||
|
||||
/**
|
||||
* @brief init Initialises all needed classes for the WebSocketInterface
|
||||
* @return True on success, otherwise false
|
||||
*/
|
||||
bool init();
|
||||
|
||||
/**
|
||||
* @brief webSocketPort returns the listen port
|
||||
* @return listen port
|
||||
*/
|
||||
unsigned short webSocketPort() { return m_webSocketServer->webSocketPort(); }
|
||||
|
||||
private:
|
||||
void cleanup();
|
||||
|
||||
private:
|
||||
LtsWebSocket::LtsWebSocketServer *m_webSocketServer;
|
||||
Messages::ClientMessageFactory *m_messageFactory;
|
||||
DataManager *m_dataManager;
|
||||
MainHandler *m_mainHandler;
|
||||
LOGGER_T m_logger;
|
||||
}; // class WebSocketInterfaceHandle
|
||||
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace ParticipantManagement
|
||||
Reference in new issue
Block a user