mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Proto- and Flatbuffer now share their input to all instances
Signed-off-by: Paulchen-Panther <Paulchen-Panter@protonmail.com>
This commit is contained in:
@@ -23,7 +23,6 @@ ProtoClientConnection::ProtoClientConnection(QTcpSocket* socket, const int &time
|
||||
, _timeoutTimer(new QTimer(this))
|
||||
, _timeout(timeout * 1000)
|
||||
, _priority()
|
||||
, _hyperion(HyperionIManager::getInstance()->getHyperionInstance())
|
||||
{
|
||||
// timer setup
|
||||
_timeoutTimer->setSingleShot(true);
|
||||
@@ -80,8 +79,8 @@ void ProtoClientConnection::forceClose()
|
||||
void ProtoClientConnection::disconnected()
|
||||
{
|
||||
Debug(_log, "Socket Closed");
|
||||
_socket->deleteLater();
|
||||
_hyperion->clear(_priority);
|
||||
_socket->deleteLater();
|
||||
emit clearGlobalInput(_priority);
|
||||
emit clientDisconnected();
|
||||
}
|
||||
|
||||
@@ -134,13 +133,13 @@ void ProtoClientConnection::handleColorCommand(const proto::ColorRequest &messag
|
||||
// make sure the prio is registered before setColor()
|
||||
if(priority != _priority)
|
||||
{
|
||||
_hyperion->clear(_priority);
|
||||
_hyperion->registerInput(priority, hyperion::COMP_PROTOSERVER, "Proto@"+_clientAddress);
|
||||
emit clearGlobalInput(_priority);
|
||||
emit registerGlobalInput(priority, hyperion::COMP_PROTOSERVER, "Proto@"+_clientAddress);
|
||||
_priority = priority;
|
||||
}
|
||||
|
||||
// set output
|
||||
_hyperion->setColor(_priority, color, duration);
|
||||
emit setGlobalInputColor(_priority, color, duration);
|
||||
|
||||
// send reply
|
||||
sendSuccessReply();
|
||||
@@ -158,8 +157,8 @@ void ProtoClientConnection::handleImageCommand(const proto::ImageRequest &messag
|
||||
// make sure the prio is registered before setInput()
|
||||
if(priority != _priority)
|
||||
{
|
||||
_hyperion->clear(_priority);
|
||||
_hyperion->registerInput(priority, hyperion::COMP_PROTOSERVER, "Proto@"+_clientAddress);
|
||||
emit clearGlobalInput(_priority);
|
||||
emit registerGlobalInput(priority, hyperion::COMP_PROTOSERVER, "Proto@"+_clientAddress);
|
||||
_priority = priority;
|
||||
}
|
||||
|
||||
@@ -174,7 +173,7 @@ void ProtoClientConnection::handleImageCommand(const proto::ImageRequest &messag
|
||||
Image<ColorRgb> image(width, height);
|
||||
memcpy(image.memptr(), imageData.c_str(), imageData.size());
|
||||
|
||||
_hyperion->setInputImage(_priority, image, duration);
|
||||
emit setGlobalInputImage(_priority, image, duration);
|
||||
|
||||
// send reply
|
||||
sendSuccessReply();
|
||||
@@ -187,15 +186,15 @@ void ProtoClientConnection::handleClearCommand(const proto::ClearRequest &messag
|
||||
int priority = message.priority();
|
||||
|
||||
// clear priority
|
||||
_hyperion->clear(priority);
|
||||
emit clearGlobalInput(priority);
|
||||
// send reply
|
||||
sendSuccessReply();
|
||||
}
|
||||
|
||||
void ProtoClientConnection::handleClearallCommand()
|
||||
{
|
||||
// clear priority
|
||||
_hyperion->clearall();
|
||||
// clear all priority
|
||||
emit clearAllGlobalInput();
|
||||
|
||||
// send reply
|
||||
sendSuccessReply();
|
||||
|
@@ -34,12 +34,42 @@ public:
|
||||
explicit ProtoClientConnection(QTcpSocket* socket, const int &timeout, QObject *parent);
|
||||
|
||||
signals:
|
||||
///
|
||||
/// @brief forward register data to HyperionDaemon
|
||||
///
|
||||
void registerGlobalInput(const int priority, const hyperion::Components& component, const QString& origin = "ProtoBuffer", const QString& owner = "", unsigned smooth_cfg = 0);
|
||||
|
||||
///
|
||||
/// @brief Forward clear command to HyperionDaemon
|
||||
///
|
||||
void clearGlobalInput(const int priority);
|
||||
|
||||
///
|
||||
/// @brief Forward clearAll command to HyperionDaemon
|
||||
///
|
||||
void clearAllGlobalInput(bool forceClearAll=false);
|
||||
|
||||
///
|
||||
/// @brief forward prepared image to HyperionDaemon
|
||||
///
|
||||
const bool setGlobalInputImage(const int priority, const Image<ColorRgb>& image, const int timeout_ms, const bool& clearEffect = false);
|
||||
|
||||
///
|
||||
/// @brief Forward requested color
|
||||
///
|
||||
void setGlobalInputColor(const int priority, const ColorRgb &ledColor, const int timeout_ms, const QString& origin = "ProtoBuffer" ,bool clearEffects = true);
|
||||
|
||||
///
|
||||
/// @brief Emits whenever the client disconnected
|
||||
///
|
||||
void clientDisconnected();
|
||||
|
||||
public slots:
|
||||
///
|
||||
/// @brief Requests a registration from the client
|
||||
///
|
||||
void registationRequired(const int priority) { if (_priority == priority) _priority = -1; };
|
||||
|
||||
///
|
||||
/// @brief close the socket and call disconnected()
|
||||
///
|
||||
@@ -127,9 +157,6 @@ private:
|
||||
int _timeout;
|
||||
int _priority;
|
||||
|
||||
/// Link to Hyperion for writing led-values to a priority channel
|
||||
Hyperion* _hyperion;
|
||||
|
||||
/// The buffer used for reading data from the socket
|
||||
QByteArray _receiveBuffer;
|
||||
};
|
||||
|
@@ -3,6 +3,7 @@
|
||||
|
||||
// util
|
||||
#include <utils/NetOrigin.h>
|
||||
#include <utils/GlobalSignals.h>
|
||||
|
||||
// qt
|
||||
#include <QJsonObject>
|
||||
@@ -68,6 +69,12 @@ void ProtoServer::newConnection()
|
||||
ProtoClientConnection * client = new ProtoClientConnection(socket, _timeout, this);
|
||||
// internal
|
||||
connect(client, &ProtoClientConnection::clientDisconnected, this, &ProtoServer::clientDisconnected);
|
||||
connect(client, &ProtoClientConnection::registerGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::registerGlobalInput);
|
||||
connect(client, &ProtoClientConnection::clearGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearGlobalInput);
|
||||
connect(client, &ProtoClientConnection::clearAllGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearAllGlobalInput);
|
||||
connect(client, &ProtoClientConnection::setGlobalInputImage, GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage);
|
||||
connect(client, &ProtoClientConnection::setGlobalInputColor, GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor);
|
||||
connect(GlobalSignals::getInstance(), &GlobalSignals::globalRegRequired, client, &ProtoClientConnection::registationRequired);
|
||||
_openConnections.append(client);
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user