Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Proxies/WirelessLocationSystem/wls_json_client_test.cpp
T
torstenandCopilot 7a6be7474e Qt6 migration: Fix BUILD_RTI=OFF build errors in TrainingAreaBase
- 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>
2026-08-23 20:49:23 +02:00

60 lines
1.6 KiB
C++
Executable File

#include "wls_json_client_test.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QStringList>
#include <QtCore/QString>
#include <QtCore/QTimer>
WlsJsonclientTest::WlsJsonclientTest(const QString &hostname, unsigned short port)
: m_socket(new QWebSocket(QString(), QWebSocketProtocol::VersionLatest, this))
, m_hostname(hostname)
, m_port(port)
{
connect(m_socket, &QWebSocket::connected, this, &WlsJsonclientTest::onConnected);
connect(m_socket, &QWebSocket::disconnected, this, &WlsJsonclientTest::onClosed);
connect(m_socket, &QWebSocket::textMessageReceived, this, &WlsJsonclientTest::onTextMessageReceived);
QTimer::singleShot(0, this, &WlsJsonclientTest::run);
}
void WlsJsonclientTest::run()
{
const QUrl url(QStringLiteral("ws://%1:%2/").arg(m_hostname).arg(m_port));
qDebug("Trying to connect to %s", qPrintable(url.toString()));
m_socket->open(url);
}
void WlsJsonclientTest::onConnected()
{
qDebug("Connected to web socket server");
}
void WlsJsonclientTest::onClosed()
{
qWarning("Socket closed - quit app");
QCoreApplication::quit();
}
void WlsJsonclientTest::onTextMessageReceived(const QString &msg)
{
qDebug("Received text msg: '%s'", qPrintable(msg));
}
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
unsigned short port = 12346;
QString hostname = QStringLiteral("localhost");
if (app.arguments().size() > 1)
hostname = app.arguments().at(1);
if (app.arguments().size() > 2)
port = app.arguments().at(2).toUShort();
WlsJsonclientTest *w = new WlsJsonclientTest(hostname, port);
int ret = app.exec();
delete w;
return ret;
}