mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
even more changes
Signed-off-by: Paulchen-Panther <Paulchen--Panter@gmx.net>
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
// hyperion util includes
|
||||
#include "utils/ColorRgb.h"
|
||||
|
||||
// Hyperion includes
|
||||
#include <hyperion/Hyperion.h>
|
||||
|
||||
// project includes
|
||||
#include "ProtoClientConnection.h"
|
||||
|
||||
@@ -198,7 +201,7 @@ void ProtoClientConnection::handleClearCommand(const proto::ClearRequest &messag
|
||||
int priority = message.priority();
|
||||
|
||||
// clear priority
|
||||
_hyperion->clear(priority);
|
||||
//_hyperion->clear(priority);
|
||||
// send reply
|
||||
sendSuccessReply();
|
||||
}
|
||||
@@ -206,7 +209,7 @@ void ProtoClientConnection::handleClearCommand(const proto::ClearRequest &messag
|
||||
void ProtoClientConnection::handleClearallCommand()
|
||||
{
|
||||
// clear priority
|
||||
_hyperion->clearall();
|
||||
//_hyperion->clearall();
|
||||
|
||||
// send reply
|
||||
sendSuccessReply();
|
||||
|
@@ -9,9 +9,6 @@
|
||||
#include <QStringList>
|
||||
#include <QString>
|
||||
|
||||
// Hyperion includes
|
||||
#include <hyperion/Hyperion.h>
|
||||
|
||||
//Utils includes
|
||||
#include <utils/VideoMode.h>
|
||||
|
||||
@@ -19,6 +16,8 @@
|
||||
#include "message.pb.h"
|
||||
#include "protoserver/ProtoConnection.h"
|
||||
|
||||
class Hyperion;
|
||||
|
||||
///
|
||||
/// The Connection object created by a ProtoServer when a new connection is establshed
|
||||
///
|
||||
|
@@ -3,10 +3,9 @@
|
||||
|
||||
// qt incl
|
||||
#include <QTcpServer>
|
||||
#include <QJsonObject>
|
||||
|
||||
// project includes
|
||||
#include <hyperion/Hyperion.h>
|
||||
#include <hyperion/MessageForwarder.h>
|
||||
#include <protoserver/ProtoServer.h>
|
||||
#include "protoserver/ProtoConnection.h"
|
||||
#include "ProtoClientConnection.h"
|
||||
@@ -15,30 +14,13 @@
|
||||
|
||||
ProtoServer::ProtoServer(const QJsonDocument& config)
|
||||
: QObject()
|
||||
, _hyperion(Hyperion::getInstance())
|
||||
, _server(new QTcpServer(this))
|
||||
, _openConnections()
|
||||
, _log(Logger::getInstance("PROTOSERVER"))
|
||||
, _componentRegister( & _hyperion->getComponentRegister())
|
||||
{
|
||||
Debug(_log,"Instance created");
|
||||
connect( _server, SIGNAL(newConnection()), this, SLOT(newConnection()));
|
||||
handleSettingsUpdate(settings::PROTOSERVER, config);
|
||||
|
||||
QStringList slaves = _hyperion->getForwarder()->getProtoSlaves();
|
||||
|
||||
for (const auto& entry : slaves)
|
||||
{
|
||||
ProtoConnection* p = new ProtoConnection(entry.toLocal8Bit().constData());
|
||||
p->setSkipReply(true);
|
||||
_proxy_connections << p;
|
||||
}
|
||||
|
||||
// listen for component changes
|
||||
connect(_componentRegister, &ComponentRegister::updatedComponentState, this, &ProtoServer::componentStateChanged);
|
||||
|
||||
// get inital forwarder state
|
||||
componentStateChanged(hyperion::COMP_FORWARDER, _componentRegister->isComponentEnabled(hyperion::COMP_FORWARDER));
|
||||
}
|
||||
|
||||
ProtoServer::~ProtoServer()
|
||||
@@ -46,9 +28,6 @@ ProtoServer::~ProtoServer()
|
||||
foreach (ProtoClientConnection * connection, _openConnections) {
|
||||
delete connection;
|
||||
}
|
||||
|
||||
while (!_proxy_connections.isEmpty())
|
||||
delete _proxy_connections.takeFirst();
|
||||
}
|
||||
|
||||
void ProtoServer::start()
|
||||
@@ -65,7 +44,13 @@ void ProtoServer::start()
|
||||
|
||||
if(_serviceRegister == nullptr)
|
||||
{
|
||||
_serviceRegister = new BonjourServiceRegister();
|
||||
_serviceRegister = new BonjourServiceRegister(this);
|
||||
_serviceRegister->registerService("_hyperiond-proto._tcp", _port);
|
||||
}
|
||||
else if( _serviceRegister->getPort() != _port)
|
||||
{
|
||||
delete _serviceRegister;
|
||||
_serviceRegister = new BonjourServiceRegister(this);
|
||||
_serviceRegister->registerService("_hyperiond-proto._tcp", _port);
|
||||
}
|
||||
}
|
||||
@@ -110,37 +95,11 @@ void ProtoServer::newConnection()
|
||||
|
||||
// register slot for cleaning up after the connection closed
|
||||
connect(connection, SIGNAL(connectionClosed(ProtoClientConnection*)), this, SLOT(closedConnection(ProtoClientConnection*)));
|
||||
connect(connection, SIGNAL(newMessage(const proto::HyperionRequest*)), this, SLOT(newMessage(const proto::HyperionRequest*)));
|
||||
|
||||
// register forward signal for video mode
|
||||
connect(this, SIGNAL(videoMode(VideoMode)), connection, SLOT(setVideoMode(VideoMode)));
|
||||
//connect(connection, SIGNAL(newMessage(const proto::HyperionRequest*)), this, SLOT(newMessage(const proto::HyperionRequest*)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProtoServer::newMessage(const proto::HyperionRequest * message)
|
||||
{
|
||||
for (int i = 0; i < _proxy_connections.size(); ++i)
|
||||
_proxy_connections.at(i)->sendMessage(*message);
|
||||
}
|
||||
|
||||
void ProtoServer::sendImageToProtoSlaves(int priority, const Image<ColorRgb> & image, int duration_ms)
|
||||
{
|
||||
if ( _forwarder_enabled )
|
||||
{
|
||||
for (int i = 0; i < _proxy_connections.size(); ++i)
|
||||
_proxy_connections.at(i)->setImage(image, priority, duration_ms);
|
||||
}
|
||||
}
|
||||
|
||||
void ProtoServer::componentStateChanged(const hyperion::Components component, bool enable)
|
||||
{
|
||||
if (component == hyperion::COMP_FORWARDER)
|
||||
{
|
||||
_forwarder_enabled = enable;
|
||||
}
|
||||
}
|
||||
|
||||
void ProtoServer::closedConnection(ProtoClientConnection *connection)
|
||||
{
|
||||
Debug(_log, "Connection closed");
|
||||
|
Reference in New Issue
Block a user