Add "enable" to forwarder, fix udp listener (#91)

* Add "enable" to forwarder

fix udp listener - address and port parsing was broken

* updated example configs

* updated example config with comments
This commit is contained in:
penfold42 2016-07-10 20:42:21 +10:00 committed by brindosch
parent 12cae1e634
commit ca795d883e
4 changed files with 6 additions and 2 deletions

View File

@ -252,12 +252,14 @@
/// The configuration of the Json/Proto forwarder. Forward messages to multiple instances of Hyperion on same and/or other hosts
/// 'proto' is mostly used for video streams and 'json' for effects
/// * enable : Enable or disable the forwarder (true/false)
/// * proto : Proto server adress and port of your target. Syntax:[IP:PORT] -> ["127.0.0.1:19447"] or more instances to forward ["127.0.0.1:19447","192.168.0.24:19449"]
/// * json : Json server adress and port of your target. Syntax:[IP:PORT] -> ["127.0.0.1:19446"] or more instances to forward ["127.0.0.1:19446","192.168.0.24:19448"]
/// HINT:If you redirect to "127.0.0.1" (localhost) you could start a second hyperion with another device/led config!
/// Be sure your client(s) is/are listening on the configured ports. The second Hyperion (if used) also needs to be configured! (HyperCon -> External -> Json Server/Proto Server)
"forwarder" :
{
"enable" : false,
"proto" : ["127.0.0.1:19447"],
"json" : ["127.0.0.1:19446"]
},

View File

@ -149,6 +149,7 @@
"forwarder" :
{
"enable" : false,
"json" : ["127.0.0.1:19446"],
"proto" : ["127.0.0.1:19447"]
},

View File

@ -522,7 +522,7 @@ LedDevice * Hyperion::createColorSmoothing(const Json::Value & smoothingConfig,
MessageForwarder * Hyperion::createMessageForwarder(const Json::Value & forwarderConfig)
{
MessageForwarder * forwarder = new MessageForwarder();
if ( ! forwarderConfig.isNull() )
if ( ( ! forwarderConfig.isNull() ) && ( forwarderConfig.get("enable", true).asBool() ) )
{
if ( ! forwarderConfig["json"].isNull() && forwarderConfig["json"].isArray() )
{

View File

@ -20,10 +20,11 @@ UDPListener::UDPListener(const int priority, const int timeout, const std::strin
_ledColors(Hyperion::getInstance()->getLedCount(), ColorRgb::BLACK),
_log(Logger::getInstance("UDPLISTENER")),
_isActive(false),
_listenPort(listenPort),
_bondage(shared ? QAbstractSocket::ShareAddress : QAbstractSocket::DefaultForPlatform)
{
_server = new QUdpSocket(this);
QHostAddress listenAddress = address.empty()
_listenAddress = address.empty()
? QHostAddress::AnyIPv4
: QHostAddress( QString::fromStdString(address) );