hyperion.ng
UDPListener.h
1 #pragma once
2 
3 // system includes
4 #include <cstdint>
5 
6 // Qt includes
7 #include <QSet>
8 #include <QHostAddress>
9 #include <QJsonDocument>
10 
11 // Hyperion includes
12 #include <utils/Logger.h>
13 #include <utils/Components.h>
14 #include <utils/ColorRgb.h>
15 
16 // settings
17 #include <utils/settings.h>
18 
20 class QUdpSocket;
21 
25 class UDPListener : public QObject
26 {
27  Q_OBJECT
28 
29 public:
35  UDPListener(const QJsonDocument& config);
36  ~UDPListener();
37 
41  uint16_t getPort() const;
42 
46  bool active() { return _isActive; };
47 
48 public slots:
52  void start();
53 
57  void stop();
58 
59  void componentStateChanged(const hyperion::Components component, bool enable);
60 
66  void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config);
67 
68 signals:
72  void registerGlobalInput(const int priority, const hyperion::Components& component, const QString& origin = "System", const QString& owner = "", unsigned smooth_cfg = 0);
73 
77  const bool setGlobalInput(const int priority, const std::vector<ColorRgb>& ledColors, const int timeout_ms = -1, const bool& clearEffect = true);
78 
79 private slots:
83  void readPendingDatagrams();
84  void processTheDatagram(const QByteArray * datagram, const QHostAddress * sender);
85 
86 private:
88  QUdpSocket * _server;
89 
91  int _priority;
92 
94  int _timeout;
95 
97  Logger * _log;
98 
100  BonjourServiceRegister* _serviceRegister = nullptr;
101 
103  bool _isActive;
104 
106  QHostAddress _listenAddress;
107  uint16_t _listenPort;
108  QAbstractSocket::BindFlag _bondage;
109 };
Definition: Logger.h:32
void handleSettingsUpdate(const settings::type &type, const QJsonDocument &config)
Handle settings update from Hyperion Settingsmanager emit or this constructor.
Definition: UDPListener.cpp:142
const bool setGlobalInput(const int priority, const std::vector< ColorRgb > &ledColors, const int timeout_ms=-1, const bool &clearEffect=true)
forward led data to HyperionDaemon
void registerGlobalInput(const int priority, const hyperion::Components &component, const QString &origin="System", const QString &owner="", unsigned smooth_cfg=0)
forward register data to HyperionDaemon
uint16_t getPort() const
Definition: UDPListener.cpp:104
void stop()
close server
Definition: UDPListener.cpp:81
UDPListener(const QJsonDocument &config)
UDPListener constructor.
Definition: UDPListener.cpp:17
Definition: bonjourserviceregister.h:43
Components
Enumeration of components in Hyperion.
Definition: Components.h:10
void start()
bind server to network
Definition: UDPListener.cpp:41
This class creates a UDP server which accepts connections from boblight clients.
Definition: UDPListener.h:25
bool active()
Definition: UDPListener.h:46