- training_area_telegrams.cpp: Fixed QJsonObject initializer syntax (Qt6 requires {{}} not ({}))
- training_area_telegrams.cpp: Fixed fromJson() methods to access m_* members directly
- training_area_telegrams.cpp: Fixed brace mismatches in multiple toJson() methods
- training_area_telegrams.h: Changed Header struct to public members for consistency
- tx_mixin.cpp: Fixed getEquipmentNumber() template for direct member access
- lts_coordinate.cpp: Added missing #include <iomanip>
- MIGRATION_STATUS.md: Added migration progress tracking document
C++17 constraint enforced due to RTI Connext DDS 7.7.0 incompatibility with C++20+
Build status: BUILD_RTI=OFF successful (0 errors, warnings only)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
64 lines
2.0 KiB
C++
64 lines
2.0 KiB
C++
|
|
|
|
#include "client_message_factory.h"
|
|
|
|
#include "client_connection.h"
|
|
#include "json_keys.h"
|
|
|
|
#include <QtCore/QJsonDocument>
|
|
|
|
namespace LtsWebSocket
|
|
{
|
|
|
|
QJsonParseError AbstractClientMessageFactory::parseMessage(const QString& message)
|
|
{
|
|
QJsonParseError error;
|
|
QJsonDocument doc = QJsonDocument::fromJson(message.toUtf8(), &error);
|
|
|
|
if (error.error != QJsonParseError::NoError)
|
|
return error;
|
|
|
|
QJsonObject obj = doc.object();
|
|
|
|
m_data = obj.value(JsonKeys::DATA());
|
|
m_type = obj.value(JsonKeys::TYPE()).toString();
|
|
m_typeId = obj.value(JsonKeys::TYPEID()).toInt();
|
|
m_uuid = obj.value(JsonKeys::UUID_()).toString();
|
|
|
|
return error;
|
|
}
|
|
|
|
AbstractClientMessage* AbstractClientMessageFactory::checkAttributes(ReplyHandler* client, const QString& message) const
|
|
{
|
|
if (!m_uuid.isEmpty() && !m_type.isEmpty())
|
|
return nullptr;
|
|
if (m_uuid.isEmpty())
|
|
{
|
|
WARNING_LOG(m_logger) << "Got message without uuid: " << message << "'";
|
|
return new LtsWebSocket::InvalidMessage(client, QString(), QStringLiteral("Got message without uuid"));
|
|
}
|
|
WARNING_LOG(m_logger) << "Got message no type: " << message << "'";
|
|
return new LtsWebSocket::InvalidMessage(client, m_uuid, QStringLiteral("Message has no type"));
|
|
}
|
|
|
|
AbstractClientMessage* AbstractClientMessageFactory::checkResult(ReplyHandler* client, const QString& message,
|
|
AbstractClientMessage* result) const
|
|
{
|
|
if (result == nullptr)
|
|
{
|
|
WARNING_LOG(m_logger) << "Could not parse message: " << message;
|
|
result = new LtsWebSocket::InvalidMessage(client, m_uuid, QStringLiteral("Invalid type"));
|
|
}
|
|
|
|
if (!result->hasValidData())
|
|
{
|
|
WARNING_LOG(m_logger) << "Resulting JSon message has invalid data... " << message;
|
|
delete result;
|
|
result = new LtsWebSocket::InvalidMessage(client, m_uuid, QStringLiteral("Has invalid data part"));
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
} // namespace LtsWebSocket
|