Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Websocket interface for ADLER WebsocketSimulator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, ESZS, 2025-03-03
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
#include <QtWebSockets/QtWebSockets>
|
||||
|
||||
#include "logger.h"
|
||||
#include <AdlerJson/generatetelegrams.h>
|
||||
|
||||
namespace AdlerWebSocketSimulator {
|
||||
|
||||
|
||||
enum AWSS_STATE {
|
||||
Unconnected,
|
||||
ConnectToServer,
|
||||
ConnectedToServer,
|
||||
RequestServicePorts,
|
||||
ConnectToParticipantManagement,
|
||||
ConnectedToParticipantManagement,
|
||||
RequestExerciseInformation,
|
||||
ConnectToExerciseManagement,
|
||||
ConnectedToExerciseManagement,
|
||||
RequestPartyInformation,
|
||||
ConnectToProxy,
|
||||
ConnectedToProxy,
|
||||
};
|
||||
|
||||
class WebSocketInterface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WebSocketInterface(QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief disconnects and resets everyting to startuip.
|
||||
*
|
||||
*/
|
||||
void reset();
|
||||
|
||||
signals:
|
||||
void gotServiceData(const QString &message);
|
||||
void gotExerciseData(const QString &message);
|
||||
void gotPartyData(const QString &message);
|
||||
void connectedToExercise();
|
||||
void connectedToParty(int id, const QString &name, int saaId);
|
||||
|
||||
/**
|
||||
* @brief emits a Status Message during operations.
|
||||
*
|
||||
*/
|
||||
void statusMessage(const QString& message);
|
||||
/**
|
||||
* @brief emits a an incommin message from proxy.
|
||||
*
|
||||
*/
|
||||
void proxyMessage(const QString& message);
|
||||
|
||||
private:
|
||||
void requestServicePortInformation();
|
||||
void requestExcerciseInformation();
|
||||
void requestPartyInformation();
|
||||
void sendFlugbahndaten(QString uuid);
|
||||
|
||||
public slots:
|
||||
void connectToServer(const QString servername, int port, int saaId);
|
||||
void connectToExerciseManagement(int port);
|
||||
void connectToParticipantManagement(int port);
|
||||
void connectToProxy(int port, int partyId, const QString &partyName);
|
||||
void sendToProxy(const QString &message);
|
||||
|
||||
|
||||
|
||||
private slots:
|
||||
void onTextMessageRecived(const QString &message);
|
||||
void onConnected();
|
||||
void onReconnect();
|
||||
void onDisconnected();
|
||||
|
||||
void onError(QAbstractSocket::SocketError error);
|
||||
|
||||
private:
|
||||
QWebSocket *m_socket {nullptr};
|
||||
AWSS_STATE m_awss_state {AWSS_STATE::Unconnected};
|
||||
|
||||
QString m_hostname {QString()};
|
||||
int m_port {0};
|
||||
int m_saaId {0};
|
||||
int m_partyId {0};
|
||||
QString m_partyName {QString()};
|
||||
|
||||
LOGGER_T m_logger;
|
||||
|
||||
};
|
||||
} // namespace AdlerWebSocketSimulator
|
||||
Reference in new issue
Block a user