Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Proxies/TrainingAreaBase/Plugins/AdlerJson/ws_handler.h
T
berrux-dev 855b0a6101 Remove modules not compiled by this branch's release build
Lts/Common: drop the 17 submodules excluded from the RELEASE_BUILD
branch of Lts/Common/CMakeLists.txt (CodeGen, LtsAppManager, LtsBotan,
LtsCoordinate, LtsElevation, LtsLogin, LtsMultiMonitor,
LtsPluginManager, LtsPrinting, LtsProjectionWorkstation,
LtsScriptTimeline, LtsSession, LtsTimeline, LtsTimelineClassic,
LtsVirtualKeyboard, LtsWidgets, TopicEditorBase). Only the 13
subdirectories actually built remain.

TrainingAreaBase: drop sources of targets excluded by
IF(NOT RELEASE_BUILD) / IF(BUILD_RTI) (svcTabClient, svcTabServer,
svcTrainingAreaBase exe, RecordReplayPlugin customization) and the 7
plugin directories not added in the release path (AdlerJson,
ApacheHlaJson, DebugJsonDir, HlaJson, Nmea, UAS, WlsTetra). Only
tabTelegrams, svcTabCommon and the TetraJson plugin are compiled.

Cross-checked: no kept compiled source includes headers from the
removed modules (GuiPluginInterface - the only LtsWidgets consumer -
is itself NOT RELEASE_BUILD-guarded).
2026-10-13 19:19:55 +02:00

79 lines
2.2 KiB
C++
Executable File

#pragma once
#include "ws_interface.h"
#include "logger.h"
#include <TrainingAreaBase/training_area_telegrams.h>
#include <QtWebSockets/QWebSocketServer>
#include <QtCore/QObject>
#include <memory>
namespace TrainingAreaBase
{
class WebSocketWrapper;
class WebSocketHandler : public WebSocketInterface
{
Q_OBJECT
public:
explicit WebSocketHandler(QObject *parent = nullptr);
~WebSocketHandler();
public:
bool init(quint16 listenPort) override;
bool isConnected() const override;
quint16 getPort() const override;
bool sendTelegram(const int typeId, const QJsonObject *data, const int exerciseId) override;
bool sendTelegram(const int wsId, const QJsonObject *data) override;
bool disconnectWs(int wsId) override;
QString getPeerAddress(int wsId) const override;
QUrl getPeerUrl(int wsId) const override;
int getExerciseId(int wsId) const override;
private Q_SLOTS:
void onNewConnection();
void onWebSocketDisconnected();
void onTextMessageReceived(const QByteArray &baJson);
private:
bool sendTelegramInternal(const TrainingAreaBase::TetraIcd::TrainingAreaTelegram *data, const QString &type, int exerciseId);
bool sendTelegramInternal(const int wsId, const TrainingAreaBase::TetraIcd::TrainingAreaTelegram *data, const QString &type, const int exerciseId);
int getWSIdFromWS( WebSocketWrapper* wsw );
private:
QWebSocketServer *m_webSocketServer;
QMap<int, std::shared_ptr<WebSocketWrapper>> m_connections;
int m_nextWsId = 1;
AdlerJson::LOGGER_T m_logger;
};
class WebSocketWrapper : public QObject
{
Q_OBJECT
public:
explicit WebSocketWrapper(QWebSocket *ws);
~WebSocketWrapper();
bool sendTextMessage(const QString &msg);
void setExerciseId(int exerciseId);
void setWsId(int wsId){ m_wsId = wsId; }
int getWsId(){ return m_wsId; }
int exerciseId() const { return m_exerciseId; }
QWebSocket *webSocket() const { return m_webSocket; }
Q_SIGNALS:
void textMessageReceived(const QByteArray &data);
private Q_SLOTS:
void onTextMessageReceived(const QString &data);
private:
QWebSocket *m_webSocket;
int m_wsId;
int m_exerciseId;
};
}