hyperion.ng
MessageForwarder.h
1 #pragma once
2 
3 // STL includes
4 #include <vector>
5 #include <map>
6 #include <cstdint>
7 #include <limits>
8 
9 // QT includes
10 #include <QList>
11 #include <QStringList>
12 #include <QHostAddress>
13 #include <QJsonObject>
14 #include <QJsonArray>
15 #include <QJsonDocument>
16 
17 // Utils includes
18 #include <utils/ColorRgb.h>
19 #include <utils/settings.h>
20 #include <utils/Logger.h>
21 #include <utils/Components.h>
22 #include <utils/Image.h>
23 
24 // Hyperion includes
25 #include <hyperion/PriorityMuxer.h>
26 
27 // Forward declaration
28 class Hyperion;
29 class QTcpSocket;
31 
32 class MessageForwarder : public QObject
33 {
34  Q_OBJECT
35 public:
38 
39  void addJsonSlave(QString slave);
40  void addProtoSlave(QString slave);
41 
42 private slots:
48  void handleSettingsUpdate(const settings::type &type, const QJsonDocument &config);
49 
55  void componentStateChanged(const hyperion::Components component, bool enable);
56 
61  void handlePriorityChanges(const quint8 &priority);
62 
67  void forwardJsonMessage(const QJsonObject &message);
68 
73  void forwardProtoMessage(const QString& name, const Image<ColorRgb> &image);
74 
80  void sendJsonMessage(const QJsonObject &message, QTcpSocket *socket);
81 
82 private:
84  Hyperion *_hyperion;
85 
87  Logger *_log;
88 
90  PriorityMuxer *_muxer;
91 
92  // JSON connection for forwarding
93  QStringList _jsonSlaves;
94 
96  QStringList _protoSlaves;
97  QList<FlatBufferConnection*> _forwardClients;
98 
100  bool _forwarder_enabled = true;
101 
102  const int _priority;
103 };
Definition: Logger.h:32
The main class of Hyperion.
Definition: Hyperion.h:57
Provide utility methods for Hyperion class.
Definition: BlackBorderDetector.h:7
Connection class to setup an connection to the hyperion server and execute commands.
Definition: FlatBufferConnection.h:24
The PriorityMuxer handles the priority channels.
Definition: PriorityMuxer.h:30
Components
Enumeration of components in Hyperion.
Definition: Components.h:10
Definition: MessageForwarder.h:32