2016-02-16 14:59:31 +01:00
|
|
|
// STL includes
|
2016-02-16 15:56:20 +01:00
|
|
|
#include <stdexcept>
|
2016-02-16 14:59:31 +01:00
|
|
|
|
2016-02-15 18:25:18 +01:00
|
|
|
#include <hyperion/MessageForwarder.h>
|
|
|
|
|
|
|
|
|
2016-02-15 20:53:03 +01:00
|
|
|
MessageForwarder::MessageForwarder()
|
2016-02-15 18:25:18 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageForwarder::~MessageForwarder()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-04 22:17:42 +01:00
|
|
|
void MessageForwarder::addJsonSlave(QString slave)
|
2016-02-15 18:25:18 +01:00
|
|
|
{
|
2017-03-04 22:17:42 +01:00
|
|
|
QStringList parts = slave.split(":");
|
2016-02-15 20:53:03 +01:00
|
|
|
if (parts.size() != 2)
|
2017-03-04 22:17:42 +01:00
|
|
|
throw std::runtime_error(QString("HYPERION (forwarder) ERROR: Wrong address: unable to parse address (%1)").arg(slave).toStdString());
|
2016-02-15 20:53:03 +01:00
|
|
|
|
|
|
|
bool ok;
|
|
|
|
quint16 port = parts[1].toUShort(&ok);
|
|
|
|
if (!ok)
|
2016-03-23 17:40:34 +01:00
|
|
|
throw std::runtime_error(QString("HYPERION (forwarder) ERROR: Wrong address: Unable to parse the port number (%1)").arg(parts[1]).toStdString());
|
2016-02-15 20:53:03 +01:00
|
|
|
|
|
|
|
JsonSlaveAddress c;
|
|
|
|
c.addr = QHostAddress(parts[0]);
|
|
|
|
c.port = port;
|
|
|
|
_jsonSlaves << c;
|
2016-02-15 18:25:18 +01:00
|
|
|
}
|
|
|
|
|
2017-03-04 22:17:42 +01:00
|
|
|
void MessageForwarder::addProtoSlave(QString slave)
|
2016-02-15 18:25:18 +01:00
|
|
|
{
|
2017-03-04 22:17:42 +01:00
|
|
|
_protoSlaves << slave;
|
2016-02-15 18:25:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QStringList MessageForwarder::getProtoSlaves()
|
|
|
|
{
|
|
|
|
return _protoSlaves;
|
|
|
|
}
|
2016-02-15 20:53:03 +01:00
|
|
|
|
|
|
|
QList<MessageForwarder::JsonSlaveAddress> MessageForwarder::getJsonSlaves()
|
|
|
|
{
|
|
|
|
return _jsonSlaves;
|
|
|
|
}
|
2016-02-19 13:31:08 +01:00
|
|
|
|
|
|
|
bool MessageForwarder::protoForwardingEnabled()
|
|
|
|
{
|
|
|
|
return ! _protoSlaves.empty();
|
|
|
|
}
|
2016-09-07 20:10:37 +02:00
|
|
|
|
|
|
|
bool MessageForwarder::jsonForwardingEnabled()
|
|
|
|
{
|
|
|
|
return ! _jsonSlaves.empty();
|
|
|
|
}
|