-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtriggerserver.h
45 lines (31 loc) · 888 Bytes
/
triggerserver.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef TRIGGERSERVER_H
#define TRIGGERSERVER_H
#include <QObject>
#include <QUdpSocket>
class TriggerServer : public QObject
{
Q_OBJECT
Q_PROPERTY(QString mode READ mode NOTIFY modeChanged)
public:
explicit TriggerServer(int interval, quint16 port, QObject *parent = nullptr);
QString mode() const;
signals:
void trigger();
void modeChanged();
public slots:
private:
struct Peer {
Peer(QHostAddress addr, quint16 port): addr(addr), port(port) {}
QHostAddress addr;
quint16 port;
};
QList<Peer> peers;
QUdpSocket *socket = nullptr;
QString m_mode = QStringLiteral("Server mode");
QString m_modeProto = QStringLiteral("Server mode [Port: %1] with %2 clients connected");
private slots:
void handlePendingDatagrams();
protected:
void timerEvent(QTimerEvent *event);
};
#endif // TRIGGERSERVER_H