mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
- prepare general way to send (proto) messages. currently only incomming protomessages are forwarded
- begin impl. of json server Former-commit-id: 8f9237cd57ada1e84dc05e60b9ad723e47fd57b1
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
// Hyperion includes
|
||||
#include <hyperion/LedString.h>
|
||||
#include <hyperion/PriorityMuxer.h>
|
||||
#include <hyperion/MessageForwarder.h>
|
||||
|
||||
// Effect engine includes
|
||||
#include <effectengine/EffectDefinition.h>
|
||||
@@ -125,6 +126,10 @@ public slots:
|
||||
/// Tell Hyperion that the transforms have changed and the leds need to be updated
|
||||
void transformsUpdated();
|
||||
|
||||
/// Returns MessageForwarder Object
|
||||
/// @return instance of message forwarder object
|
||||
MessageForwarder * getForwarder();
|
||||
|
||||
///
|
||||
/// Clears the given priority channel. This will switch the led-colors to the colors of the next
|
||||
/// lower priority channel (or off if no more channels are set)
|
||||
@@ -168,6 +173,7 @@ public:
|
||||
static RgbChannelTransform * createRgbChannelTransform(const Json::Value& colorConfig);
|
||||
|
||||
static LedDevice * createColorSmoothing(const Json::Value & smoothingConfig, LedDevice * ledDevice);
|
||||
static MessageForwarder * createMessageForwarder(const Json::Value & forwarderConfig);
|
||||
|
||||
signals:
|
||||
/// Signal which is emitted when a priority channel is actively cleared
|
||||
@@ -201,6 +207,9 @@ private:
|
||||
/// Effect engine
|
||||
EffectEngine * _effectEngine;
|
||||
|
||||
// proto and json Message forwarder
|
||||
MessageForwarder * _messageForwarder;
|
||||
|
||||
/// The timer for handling priority channel timeouts
|
||||
QTimer _timer;
|
||||
};
|
||||
|
31
include/hyperion/MessageForwarder.h
Normal file
31
include/hyperion/MessageForwarder.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
// STL includes
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
|
||||
// QT includes
|
||||
#include <QList>
|
||||
#include <QStringList>
|
||||
|
||||
// Utils includes
|
||||
#include <utils/ColorRgb.h>
|
||||
class MessageForwarder
|
||||
{
|
||||
public:
|
||||
MessageForwarder();
|
||||
~MessageForwarder();
|
||||
|
||||
void addJsonSlave(std::string slave);
|
||||
void addProtoSlave(std::string slave);
|
||||
void sendMessage();
|
||||
|
||||
QStringList getProtoSlaves();
|
||||
|
||||
private:
|
||||
bool _running;
|
||||
|
||||
QStringList _protoSlaves;
|
||||
};
|
@@ -6,12 +6,19 @@
|
||||
// Qt includes
|
||||
#include <QTcpServer>
|
||||
#include <QSet>
|
||||
#include <QList>
|
||||
#include <QStringList>
|
||||
|
||||
// Hyperion includes
|
||||
#include <hyperion/Hyperion.h>
|
||||
|
||||
// forward decl
|
||||
class ProtoClientConnection;
|
||||
class ProtoConnection;
|
||||
|
||||
namespace proto {
|
||||
class HyperionRequest;
|
||||
}
|
||||
|
||||
///
|
||||
/// This class creates a TCP server which accepts connections wich can then send
|
||||
@@ -28,7 +35,7 @@ public:
|
||||
/// @param hyperion Hyperion instance
|
||||
/// @param port port number on which to start listening for connections
|
||||
///
|
||||
ProtoServer(Hyperion * hyperion, uint16_t port = 19445, QStringList * forwardClientList = new QStringList() );
|
||||
ProtoServer(Hyperion * hyperion, uint16_t port = 19445);
|
||||
~ProtoServer();
|
||||
|
||||
///
|
||||
@@ -48,6 +55,8 @@ private slots:
|
||||
///
|
||||
void closedConnection(ProtoClientConnection * connection);
|
||||
|
||||
void newMessage(const proto::HyperionRequest * message);
|
||||
|
||||
private:
|
||||
/// Hyperion instance
|
||||
Hyperion * _hyperion;
|
||||
@@ -58,4 +67,8 @@ private:
|
||||
/// List with open connections
|
||||
QSet<ProtoClientConnection *> _openConnections;
|
||||
QStringList _forwardClients;
|
||||
|
||||
/// Hyperion proto connection object for forwarding
|
||||
QList<ProtoConnection*> _proxy_connections;
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user