diff options
| author | Dark1-dev <shansarkar272@gmail.com> | 2023-03-01 21:30:57 +0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-01 21:30:57 +0600 |
| commit | 60a301a93b6057bb2c54ac04a7c38c38389037b3 (patch) | |
| tree | b09c5f8bc0045828c660654d8ed6744663856202 /src/UdpTasks/BeaconServer/beaconserver.h | |
| parent | c784240d1af68dbd8d0466822b34fd05d6ccdda1 (diff) | |
| download | Masterserver-Qt5-60a301a93b6057bb2c54ac04a7c38c38389037b3.tar.gz Masterserver-Qt5-60a301a93b6057bb2c54ac04a7c38c38389037b3.zip | |
Add files via upload
Diffstat (limited to 'src/UdpTasks/BeaconServer/beaconserver.h')
| -rw-r--r-- | src/UdpTasks/BeaconServer/beaconserver.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/UdpTasks/BeaconServer/beaconserver.h b/src/UdpTasks/BeaconServer/beaconserver.h new file mode 100644 index 0000000..fd8532d --- /dev/null +++ b/src/UdpTasks/BeaconServer/beaconserver.h @@ -0,0 +1,66 @@ +#ifndef BEACONSERVER_H +#define BEACONSERVER_H + +#include <QTimer> +#include <QUdpSocket> +#include <QNetworkDatagram> +#include <QHostInfo> +#include "Core/CoreObject/coreobject.h" +#include "Database/Common/commonactions.h" +#include "Protocols/GameSpy0/gamespy0.h" +#include "Protocols/GameSpy0/securevalidate.h" +#include "UdpTasks/udpdatastructure.h" + +class BeaconServer : public QObject +{ + Q_OBJECT +public: + BeaconServer(const QSharedPointer<CoreObject> &coreObject); + + // activate listener and broadcast + bool listen(); + bool uplink(); + +private: // general udp task handles + QSharedPointer<CoreObject> _coreObject; + const int _timeOutTime_ms = 15000; // 15 second soft timeout + const int _broadcastInterval_s = 60; // 1 min between beacons + + // udp socket + QUdpSocket _udpSocket; + + // determine reply to incoming requests + QStringList replyQuery(const QMultiHash<QString, QString> &query); + +private: // udp beacon server + + // heartbeat processing for different protocol types + void processHeartbeatGamespy0(const QNetworkDatagram &datagram, + const QString &senderAddress, + const unsigned short &senderPort, + const QString &receiveBuffer); + + // timer to sweep up abandoned beacons (timeouts) + QTimer _sweepTimer; + + // store information about unverified beacons + QHash<QString, UdpData> _beaconList; + + // helper for replyQuery() + int _queryId; + +private slots: // udp beacon server event slots + void onUdpRead(); + void onUdpTimedOut(); + +private: // broadcast heartbeat + + // outbound heartbeat timer and content + QTimer _uplinkTimer; + QString _uplinkData; + +private slots: // broadcast heartbeat events + void onUplinkTimer(); +}; + +#endif // BEACONSERVER_H |
