Files
qt5-legatus-legacy/Lts/Services/ServiceManagement/WebSocketInterface/Messages/reply_message.cpp
T
2026-08-13 18:33:10 +02:00

70 lines
2.1 KiB
C++
Executable File

/**
* @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"
#include <QtCore/QUuid>
#include <QtCore/QJsonDocument>
namespace ServiceManagement
{
namespace WebSocketInterface
{
namespace Messages
{
using namespace JsonKeys;
using namespace LtsWebSocket::JsonKeys;
// ####### ServicePortsInformationMessage begin #######
/********************************************************
* Warning: 6002 has been negotiated with ESG for ADLER *
********************************************************/
ServicePortsInformationMessage::ServicePortsInformationMessage(const QVector<ExerciseInformation> &data, const QString &uuid)
: ReplyMessage (SERVICE_PORTS_INFORMATION(), 6002, uuid) // Todo check whether TypeID is correct.
{
QJsonArray exercises;
for (const auto &exercise : data)
{
QJsonArray services;
for (const auto &service : exercise.services)
{
QJsonArray ports;
for (const auto &port : service.ports)
{
ports.append(QJsonObject({{NUMBER(),port.number},
{TYPE_ID(),port.type},
{PROPERTIES(), port.properties}
}));
}
services.append(QJsonObject({{NAME(), service.name},
{NAME_ABBR(), service.abbreviation},
{PORTS(), ports}
}));
}
QJsonObject obj({{EXERCISE_ID(), exercise.exerciseId},
{SERVICES(), services}
});
if (exercise.replayPartitionId.is_set())
obj.insert(REPLAY_PARTITION_ID(), exercise.replayPartitionId.get());
exercises.append(obj);
}
m_jsonRepresentation.insert(DATA(), exercises);
}
// ####### ServicePortsInformationMessage end #######
} // namespace Messages
} // namespace WebSocketInterface
} // namespace ServiceManagement