Pool Video Switch v2
Software video switch for distributed remote display in a lecture environment
serverdiscovery.h
Go to the documentation of this file.
1 #ifndef SERVERDISCOVERY_H
2 #define SERVERDISCOVERY_H
3 
4 #include <QObject>
5 #include <QUdpSocket>
6 #include <QTimer>
7 #include "../../shared/networkmessage.h"
8 
9 class ServerDiscovery : public QObject
10 {
11  Q_OBJECT
12 
13 public:
14  enum class ErrorType
15  {
18  };
19 
20  explicit ServerDiscovery(QObject *parent = nullptr);
21  ~ServerDiscovery() override;
22 
23  void start(const QByteArray& sessionName, const QString& mgrIP);
24  void stop();
25  inline bool isActive() { return _discoveryTimer.isActive(); }
26 
27 private:
33  QByteArray _nameBytes;
34  QByteArray _salt2;
35  QUdpSocket _discoverySocket;
37 
38  QHostAddress _mgrIP;
39 
40  static const int UDPBUFSIZ = 9000;
41  static const int SALT_LEN = 18;
42 
43 signals:
44  void serverDetected(const QString& host, const quint16 port, const QByteArray& sessionName, const QByteArray& certHash, bool autoConnect);
45  void error(ErrorType e, int count);
46 
47 public slots:
48 
49 private slots:
50  void doDiscovery();
51  void onUdpReadyRead();
52 
53 };
54 
55 #endif // SERVERDISCOVERY_H
QUdpSocket _discoverySocket
ServerDiscovery(QObject *parent=nullptr)
Ctor.
void error(ErrorType e, int count)
NetworkMessage _packet
QByteArray _salt2
const int _minDiscoveryInterval
void start(const QByteArray &sessionName, const QString &mgrIP)
start
const int _maxDiscoveryInterval
~ServerDiscovery() override
Dtor.
void onUdpReadyRead()
Handle incoming service discovery packets.
static const int SALT_LEN
QHostAddress _mgrIP
QByteArray _nameBytes
static const int UDPBUFSIZ
void serverDetected(const QString &host, const quint16 port, const QByteArray &sessionName, const QByteArray &certHash, bool autoConnect)
void doDiscovery()
ConnectWindow::doDiscovery.