This commit is contained in:
Paulchen Panther 2020-10-18 17:05:07 +02:00 committed by GitHub
parent 9d2e442d42
commit aa465c018c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 207 additions and 90 deletions

3
.gitignore vendored
View File

@ -22,3 +22,6 @@ compile_commands.json
# Autogenerated by flatbuffers
libsrc/flatbufserver/hyperion_reply_generated.h
libsrc/flatbufserver/hyperion_request_generated.h
# Kdevelop project files
*.kdev*

View File

@ -112,8 +112,9 @@ protected:
/// @param dat The effect data
/// @param callerComp The HYPERION COMPONENT that calls this function! e.g. PROT/FLATBUF
/// REQUIRED dat fields: effectName, priority, duration, origin
/// @return True on success else false
///
void setEffect(const EffectCmdData &dat, hyperion::Components callerComp = hyperion::COMP_INVALID);
bool setEffect(const EffectCmdData &dat, hyperion::Components callerComp = hyperion::COMP_INVALID);
///
/// @brief Set source auto select enabled or disabled
@ -174,8 +175,10 @@ protected:
///
/// @brief Start instance
/// @param index The instance index
/// @param tan The tan
/// @return True on success else false
///
void startInstance(quint8 index);
bool startInstance(quint8 index, int tan = 0);
///
/// @brief Stop instance
@ -277,8 +280,9 @@ protected:
/// @brief Set a new token request
/// @param comment The comment
/// @param id The id
/// @param tan The tan
///
void setNewTokenRequest(const QString &comment, const QString &id);
void setNewTokenRequest(const QString &comment, const QString &id, const int &tan);
///
/// @brief Cancel new token request
@ -367,7 +371,7 @@ signals:
///
/// @brief Emits whenever a new Token request is pending. This signal is just active when ADMIN ACCESS has been granted
/// @param id The id of the request
/// @param id The id of the request
/// @param comment The comment of the request; If the commen is EMPTY the request has been revoked by the caller. So remove it from the pending list
///
void onPendingTokenRequest(const QString &id, const QString &comment);
@ -378,8 +382,15 @@ signals:
/// @param token The new token that is now valid
/// @param comment The comment that was part of the request
/// @param id The id that was part of the request
/// @param tan The tan that was part of the request
///
void onTokenResponse(bool success, const QString &token, const QString &comment, const QString &id);
void onTokenResponse(bool success, const QString &token, const QString &comment, const QString &id, const int &tan);
///
/// @brief Handle emits from HyperionIManager of startInstance request, just if QObject matches with this instance it will emit.
/// @param tan The tan that was part of the request
///
void onStartInstanceResponse(const int &tan);
private slots:
///
@ -388,16 +399,6 @@ private slots:
///
void requestActiveRegister(QObject *callerInstance);
///
/// @brief See onTokenResponse(). Here we validate the caller instance and on success we will emit onTokenResponse()
/// @param success If true the request was accepted else false and no token was created
/// @param caller The origin caller instance who requested this token
/// @param token The new token that is now valid
/// @param comment The comment that was part of the request
/// @param id The id that was part of the request
///
void checkTokenResponse(bool success, QObject *caller, const QString &token, const QString &comment, const QString &id);
private:
void stopDataConnectionss();

View File

@ -65,8 +65,8 @@ public slots:
private slots:
///
/// @brief Handle emits from API of a new Token request.
/// @param id The id of the request
/// @param The comment which needs to be accepted
/// @param id The id of the request
/// @param comment The comment which needs to be accepted
///
void newPendingTokenRequest(const QString &id, const QString &comment);
@ -76,8 +76,9 @@ private slots:
/// @param token The new token that is now valid
/// @param comment The comment that was part of the request
/// @param id The id that was part of the request
/// @param tan The tan that was part of the request
///
void handleTokenResponse(bool success, const QString &token, const QString &comment, const QString &id);
void handleTokenResponse(bool success, const QString &token, const QString &comment, const QString &id, const int &tan);
///
/// @brief Handle whenever the state of a instance (HyperionIManager) changes according to enum instanceState

View File

@ -29,6 +29,7 @@ public:
QString id;
QString comment;
QObject *caller;
int tan;
uint64_t timeoutTime;
QString token;
QString lastUse;
@ -142,16 +143,16 @@ public slots:
/// @param caller The QObject of the caller to deliver the reply
/// @param comment The comment as ident helper
/// @param id The id created by the caller
/// @param tan The tan created by the caller
///
void setNewTokenRequest(QObject *caller, const QString &comment, const QString &id);
void setNewTokenRequest(QObject *caller, const QString &comment, const QString &id, const int &tan = 0);
///
/// @brief Cancel a pending token request with the provided comment and id as identifier helper
/// @param caller The QObject of the caller to deliver the reply
/// @param comment The comment as ident helper
/// @param id The id created by the caller
///
void cancelNewTokenRequest(QObject *caller, const QString &comment, const QString &id);
void cancelNewTokenRequest(QObject *caller, const QString &, const QString &id);
///
/// @brief Handle a token request by id, generate token and inform token caller or deny
@ -200,8 +201,9 @@ signals:
/// @param token The new token that is now valid
/// @param comment The comment that was part of the request
/// @param id The id that was part of the request
/// @param tan The tan that was part of the request
///
void tokenResponse(bool success, QObject *caller, const QString &token, const QString &comment, const QString &id);
void tokenResponse(bool success, QObject *caller, const QString &token, const QString &comment, const QString &id, const int &tan);
///
/// @brief Emits whenever the token list changes

View File

@ -28,6 +28,12 @@ class HyperionIManager : public QObject
Q_OBJECT
public:
struct PendingRequests
{
QObject *caller;
int tan;
};
// global instance pointer
static HyperionIManager* getInstance() { return HIMinstance; }
static HyperionIManager* HIMinstance;
@ -54,11 +60,11 @@ public slots:
///
/// @brief Start a Hyperion instance
/// @param instance Instance index
/// @param block If true return when thread has been started
/// @param instance Instance index
/// @param block If true return when thread has been started
/// @return Return true on success, false if not found in db
///
bool startInstance(quint8 inst, bool block = false);
bool startInstance(quint8 inst, bool block = false, QObject *caller = nullptr, int tan = 0);
///
/// @brief Stop a Hyperion instance
@ -110,6 +116,13 @@ signals:
///
void change();
///
/// @brief Emits when the user has requested to start a instance
/// @param caller The origin caller instance who requested
/// @param tan The tan that was part of the request
///
void startInstanceResponse(QObject *caller, const int &tan);
signals:
///////////////////////////////////////
/// FROM HYPERIONDAEMON TO HYPERION ///
@ -180,4 +193,6 @@ private:
const QString _rootPath;
QMap<quint8, Hyperion*> _runningInstances;
QList<quint8> _startQueue;
/// All pending requests
QMap<quint8, PendingRequests> _pendingRequests;
};

View File

@ -20,7 +20,7 @@ class SSDPHandler : public SSDPServer
{
Q_OBJECT
public:
SSDPHandler(WebServer* webserver, quint16 flatBufPort, quint16 jsonServerPort, const QString &name, QObject * parent = nullptr);
SSDPHandler(WebServer* webserver, quint16 flatBufPort, quint16 protoBufPort, quint16 jsonServerPort, quint16 sslPort, const QString &name, QObject * parent = nullptr);
~SSDPHandler() override;
///

View File

@ -85,16 +85,36 @@ public:
quint16 getFlatBufPort() const { return _fbsPort.toInt(); };
///
/// @brief set new jsonserver server port
/// @brief set new protobuf server port
///
void setProtoBufPort(quint16 port) { _pbsPort = QString::number(port); };
///
/// @brief Get current protobuf server port
///
quint16 getProtoBufPort() const { return _pbsPort.toInt(); };
///
/// @brief set new json server port
///
void setJsonServerPort(quint16 port) { _jssPort = QString::number(port); };
///
/// @brief get new jsonserver server port
/// @brief get new json server port
///
quint16 getJsonServerPort() const { return _jssPort.toInt(); };
///
///
/// @brief set new ssl server port
///
void setSSLServerPort(quint16 port) { _sslPort = QString::number(port); };
///
/// @brief get new ssl server port
///
quint16 getSSLServerPort() const { return _sslPort.toInt(); };
///
/// @brief set new hyperion name
///
void setHyperionName(const QString &name) { _name = name; };
@ -119,13 +139,15 @@ private:
Logger* _log;
QUdpSocket* _udpSocket;
QString _serverHeader;
QString _uuid;
QString _fbsPort;
QString _jssPort;
QString _name;
QString _descAddress;
bool _running;
QString _serverHeader,
_uuid,
_fbsPort,
_pbsPort,
_jssPort,
_sslPort,
_name,
_descAddress;
bool _running;
private slots:
void readPendingDatagrams();

View File

@ -56,7 +56,18 @@ API::API(Logger *log, bool localConnection, QObject *parent)
//connect(ApiSync::getInstance(), &ApiSync::requestActiveRegister, this, &API::requestActiveRegister, Qt::QueuedConnection);
// connect to possible token responses that has been requested
connect(_authManager, &AuthManager::tokenResponse, this, &API::checkTokenResponse);
connect(_authManager, &AuthManager::tokenResponse, [=] (bool success, QObject *caller, const QString &token, const QString &comment, const QString &id, const int &tan)
{
if (this == caller)
emit onTokenResponse(success, token, comment, id, tan);
});
// connect to possible startInstance responses that has been requested
connect(_instanceManager, &HyperionIManager::startInstanceResponse, [=] (QObject *caller, const int &tan)
{
if (this == caller)
emit onStartInstanceResponse(tan);
});
}
void API::init()
@ -211,16 +222,19 @@ void API::setVideoMode(VideoMode mode, hyperion::Components callerComp)
QMetaObject::invokeMethod(_hyperion, "setVideoMode", Qt::QueuedConnection, Q_ARG(VideoMode, mode));
}
void API::setEffect(const EffectCmdData &dat, hyperion::Components callerComp)
bool API::setEffect(const EffectCmdData &dat, hyperion::Components callerComp)
{
int res;
if (!dat.args.isEmpty())
{
QMetaObject::invokeMethod(_hyperion, "setEffect", Qt::QueuedConnection, Q_ARG(QString, dat.effectName), Q_ARG(QJsonObject, dat.args), Q_ARG(int, dat.priority), Q_ARG(int, dat.duration), Q_ARG(QString, dat.pythonScript), Q_ARG(QString, dat.origin), Q_ARG(QString, dat.data));
QMetaObject::invokeMethod(_hyperion, "setEffect", Qt::BlockingQueuedConnection, Q_RETURN_ARG(int, res), Q_ARG(QString, dat.effectName), Q_ARG(QJsonObject, dat.args), Q_ARG(int, dat.priority), Q_ARG(int, dat.duration), Q_ARG(QString, dat.pythonScript), Q_ARG(QString, dat.origin), Q_ARG(QString, dat.data));
}
else
{
QMetaObject::invokeMethod(_hyperion, "setEffect", Qt::QueuedConnection, Q_ARG(QString, dat.effectName), Q_ARG(int, dat.priority), Q_ARG(int, dat.duration), Q_ARG(QString, dat.origin));
QMetaObject::invokeMethod(_hyperion, "setEffect", Qt::BlockingQueuedConnection, Q_RETURN_ARG(int, res), Q_ARG(QString, dat.effectName), Q_ARG(int, dat.priority), Q_ARG(int, dat.duration), Q_ARG(QString, dat.origin));
}
return res >= 0;
}
void API::setSourceAutoSelect(bool state, hyperion::Components callerComp)
@ -285,9 +299,14 @@ QVector<QVariantMap> API::getAllInstanceData()
return vec;
}
void API::startInstance(quint8 index)
bool API::startInstance(quint8 index, int tan)
{
QMetaObject::invokeMethod(_instanceManager, "startInstance", Qt::QueuedConnection, Q_ARG(quint8, index));
bool res;
(_instanceManager->thread() != this->thread())
? QMetaObject::invokeMethod(_instanceManager, "startInstance", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, res), Q_ARG(quint8, index), Q_ARG(bool, false), Q_ARG(QObject*, this), Q_ARG(int, tan))
: res = _instanceManager->startInstance(index, false, this, tan);
return res;
}
void API::stopInstance(quint8 index)
@ -407,9 +426,9 @@ QString API::deleteToken(const QString &id)
return "";
}
void API::setNewTokenRequest(const QString &comment, const QString &id)
void API::setNewTokenRequest(const QString &comment, const QString &id, const int &tan)
{
QMetaObject::invokeMethod(_authManager, "setNewTokenRequest", Qt::QueuedConnection, Q_ARG(QObject *, this), Q_ARG(QString, comment), Q_ARG(QString, id));
QMetaObject::invokeMethod(_authManager, "setNewTokenRequest", Qt::QueuedConnection, Q_ARG(QObject *, this), Q_ARG(QString, comment), Q_ARG(QString, id), Q_ARG(int, tan));
}
void API::cancelNewTokenRequest(const QString &comment, const QString &id)
@ -465,12 +484,11 @@ bool API::getUserToken(QString &userToken)
bool API::isTokenAuthorized(const QString &token)
{
bool res;
QMetaObject::invokeMethod(_authManager, "isTokenAuthorized", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, res), Q_ARG(QString, token));
if (res)
_authorized = true;
(_authManager->thread() != this->thread())
? QMetaObject::invokeMethod(_authManager, "isTokenAuthorized", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, _authorized), Q_ARG(QString, token))
: _authorized = _authManager->isTokenAuthorized(token);
return res;
return _authorized;
}
bool API::isUserAuthorized(const QString &password)
@ -503,12 +521,6 @@ void API::logout()
stopDataConnectionss();
}
void API::checkTokenResponse(bool success, QObject *caller, const QString &token, const QString &comment, const QString &id)
{
if (this == caller)
emit onTokenResponse(success, token, comment, id);
}
void API::stopDataConnectionss()
{
}

View File

@ -243,9 +243,10 @@ void JsonAPI::handleEffectCommand(const QJsonObject &message, const QString &com
dat.data = message["imageData"].toString("").toUtf8();
dat.args = message["effect"].toObject()["args"].toObject();
API::setEffect(dat);
sendSuccessReply(command, tan);
if (API::setEffect(dat))
sendSuccessReply(command, tan);
else
sendErrorReply("Effect '" + dat.effectName + "' not found", command, tan);
}
void JsonAPI::handleCreateEffectCommand(const QJsonObject &message, const QString &command, int tan)
@ -351,8 +352,10 @@ void JsonAPI::handleServerInfoCommand(const QJsonObject &message, const QString
item["value"] = LEDcolor;
}
// priorities[priorities.size()] = item;
priorities.append(item);
(priority == currentPriority)
? priorities.prepend(item)
: priorities.append(item);
}
info["priorities"] = priorities;
@ -1186,7 +1189,7 @@ void JsonAPI::handleAuthorizeCommand(const QJsonObject &message, const QString &
const QString &comment = message["comment"].toString().trimmed();
const bool &acc = message["accept"].toBool(true);
if (acc)
API::setNewTokenRequest(comment, id);
API::setNewTokenRequest(comment, id, tan);
else
API::cancelNewTokenRequest(comment, id);
// client should wait for answer
@ -1323,9 +1326,10 @@ void JsonAPI::handleInstanceCommand(const QJsonObject &message, const QString &c
if (subc == "startInstance")
{
// silent fail
API::startInstance(inst);
sendSuccessReply(command + "-" + subc, tan);
connect(this, &API::onStartInstanceResponse, [=] (const int &tan) { sendSuccessReply(command + "-" + subc, tan); });
if (!API::startInstance(inst, tan))
sendErrorReply("Can't start Hyperion instance index " + QString::number(inst), command + "-" + subc, tan);
return;
}
@ -1557,7 +1561,7 @@ void JsonAPI::newPendingTokenRequest(const QString &id, const QString &comment)
sendSuccessDataReply(QJsonDocument(obj), "authorize-tokenRequest", 1);
}
void JsonAPI::handleTokenResponse(bool success, const QString &token, const QString &comment, const QString &id)
void JsonAPI::handleTokenResponse(bool success, const QString &token, const QString &comment, const QString &id, const int &tan)
{
const QString cmd = "authorize-requestToken";
QJsonObject result;
@ -1566,9 +1570,9 @@ void JsonAPI::handleTokenResponse(bool success, const QString &token, const QStr
result["id"] = id;
if (success)
sendSuccessDataReply(QJsonDocument(result), cmd);
sendSuccessDataReply(QJsonDocument(result), cmd, tan);
else
sendErrorReply("Token request timeout or denied", cmd, 5);
sendErrorReply("Token request timeout or denied", cmd, tan);
}
void JsonAPI::handleInstanceStateChange(InstanceState state, quint8 instance, const QString &name)

View File

@ -141,8 +141,6 @@ int EffectEngine::runEffect(const QString &effectName, int priority, int timeout
int EffectEngine::runEffect(const QString &effectName, const QJsonObject &args, int priority, int timeout, const QString &pythonScript, const QString &origin, unsigned smoothCfg, const QString &imageData)
{
Info( _log, "Run effect \"%s\" on channel %d", QSTRING_CSTR(effectName), priority);
if (pythonScript.isEmpty())
{
const EffectDefinition *effectDefinition = nullptr;
@ -157,12 +155,14 @@ int EffectEngine::runEffect(const QString &effectName, const QJsonObject &args,
if (effectDefinition == nullptr)
{
// no such effect
Error(_log, "Effect %s not found", QSTRING_CSTR(effectName));
Error(_log, "Effect \"%s\" not found", QSTRING_CSTR(effectName));
return -1;
}
Info( _log, "Run effect \"%s\" on channel %d", QSTRING_CSTR(effectName), priority);
return runEffectScript(effectDefinition->script, effectName, (args.isEmpty() ? effectDefinition->args : args), priority, timeout, origin, effectDefinition->smoothCfg);
}
Info( _log, "Run effect \"%s\" on channel %d", QSTRING_CSTR(effectName), priority);
return runEffectScript(pythonScript, effectName, args, priority, timeout, origin, smoothCfg, imageData);
}

View File

@ -150,18 +150,18 @@ bool AuthManager::resetHyperionUser()
return _authTable->resetHyperionUser();
}
void AuthManager::setNewTokenRequest(QObject *caller, const QString &comment, const QString &id)
void AuthManager::setNewTokenRequest(QObject *caller, const QString &comment, const QString &id, const int &tan)
{
if (!_pendingRequests.contains(id))
{
AuthDefinition newDef{id, comment, caller, uint64_t(QDateTime::currentMSecsSinceEpoch() + 180000)};
AuthDefinition newDef{id, comment, caller, tan, uint64_t(QDateTime::currentMSecsSinceEpoch() + 180000)};
_pendingRequests[id] = newDef;
_timer->start();
emit newPendingTokenRequest(id, comment);
}
}
void AuthManager::cancelNewTokenRequest(QObject *caller, const QString &comment, const QString &id)
void AuthManager::cancelNewTokenRequest(QObject *caller, const QString &, const QString &id)
{
if (_pendingRequests.contains(id))
{
@ -182,12 +182,12 @@ void AuthManager::handlePendingTokenRequest(const QString &id, bool accept)
{
const QString token = QUuid::createUuid().toString().remove("{").remove("}");
_authTable->createToken(token, def.comment, id);
emit tokenResponse(true, def.caller, token, def.comment, id);
emit tokenResponse(true, def.caller, token, def.comment, id, def.tan);
emit tokenChange(getTokenList());
}
else
{
emit tokenResponse(false, def.caller, QString(), def.comment, id);
emit tokenResponse(false, def.caller, QString(), def.comment, id, def.tan);
}
}
}
@ -249,7 +249,7 @@ void AuthManager::checkTimeout()
const AuthDefinition &def = i.value();
if (def.timeoutTime <= now)
{
emit tokenResponse(false, def.caller, QString(), def.comment, def.id);
emit tokenResponse(false, def.caller, QString(), def.comment, def.id, def.tan);
_pendingRequests.remove(i.key());
}
}

View File

@ -67,7 +67,7 @@ void HyperionIManager::toggleStateAllInstances(bool pause)
}
}
bool HyperionIManager::startInstance(quint8 inst, bool block)
bool HyperionIManager::startInstance(quint8 inst, bool block, QObject* caller, int tan)
{
if(_instanceTable->instanceExist(inst))
{
@ -104,6 +104,12 @@ bool HyperionIManager::startInstance(quint8 inst, bool block)
while(!hyperionThread->isRunning()){};
}
if (!_pendingRequests.contains(inst) && caller != nullptr)
{
PendingRequests newDef{caller, tan};
_pendingRequests[inst] = newDef;
}
return true;
}
Debug(_log,"Can't start Hyperion instance index '%d' with name '%s' it's already running or queued for start", inst, QSTRING_CSTR(_instanceTable->getNamebyIndex(inst)));
@ -211,4 +217,11 @@ void HyperionIManager::handleStarted()
_runningInstances.insert(instance, hyperion);
emit instanceStateChanged(InstanceState::H_STARTED, instance);
emit change();
if (_pendingRequests.contains(instance))
{
PendingRequests def = _pendingRequests.take(instance);
emit startInstanceResponse(def.caller, def.tan);
_pendingRequests.remove(instance);
}
}

View File

@ -142,9 +142,11 @@ hyperion::Components PriorityMuxer::getComponentOfPriority(int priority) const
void PriorityMuxer::registerInput(int priority, hyperion::Components component, const QString& origin, const QString& owner, unsigned smooth_cfg)
{
// detect new registers
bool newInput = false;
if(!_activeInputs.contains(priority))
bool newInput, reusedInput = false;
if (!_activeInputs.contains(priority))
newInput = true;
else
reusedInput = true;
InputInfo& input = _activeInputs[priority];
input.priority = priority;
@ -154,12 +156,15 @@ void PriorityMuxer::registerInput(int priority, hyperion::Components component,
input.smooth_cfg = smooth_cfg;
input.owner = owner;
if(newInput)
if (newInput)
{
Debug(_log,"Register new input '%s/%s' with priority %d as inactive", QSTRING_CSTR(origin), hyperion::componentToIdString(component), priority);
emit prioritiesChanged();
if (!_sourceAutoSelectEnabled) // emit 'prioritiesChanged' only on when _sourceAutoSelectEnabled is false
emit prioritiesChanged();
return;
}
if (reusedInput) emit prioritiesChanged();
}
bool PriorityMuxer::setInput(int priority, const std::vector<ColorRgb>& ledColors, int64_t timeout_ms)
@ -339,7 +344,6 @@ void PriorityMuxer::setCurrentTime()
_prevVisComp = comp;
emit visibleComponentChanged(comp);
}
emit prioritiesChanged();
}
}

View File

@ -39,10 +39,7 @@ ProviderRestApi::ProviderRestApi()
ProviderRestApi::~ProviderRestApi()
{
if ( _networkManager != nullptr )
{
delete _networkManager;
}
delete _networkManager;
}
void ProviderRestApi::setBasePath(const QString &basePath)

View File

@ -27,6 +27,12 @@ static const QString SSDP_DESCRIPTION = "<?xml version=\"1.0\"?>"
"<modelURL>https://www.hyperion-project.org</modelURL>"
"<serialNumber>%4</serialNumber>"
"<UDN>uuid:%4</UDN>"
"<ports>"
"<jsonServer>%5</jsonServer>"
"<sslServer>%6</sslServer>"
"<protoBuffer>%7</protoBuffer>"
"<flatBuffer>%8</flatBuffer>"
"</ports>"
"<presentationURL>index.html</presentationURL>"
"<iconList>"
"<icon>"

View File

@ -15,14 +15,16 @@
static const QString SSDP_HYPERION_ST("urn:hyperion-project.org:device:basic:1");
SSDPHandler::SSDPHandler(WebServer* webserver, quint16 flatBufPort, quint16 jsonServerPort, const QString& name, QObject * parent)
SSDPHandler::SSDPHandler(WebServer* webserver, quint16 flatBufPort, quint16 protoBufPort, quint16 jsonServerPort, quint16 sslPort, const QString& name, QObject * parent)
: SSDPServer(parent)
, _webserver(webserver)
, _localAddress()
, _NCA(nullptr)
{
setFlatBufPort(flatBufPort);
setProtoBufPort(protoBufPort);
setJsonServerPort(jsonServerPort);
setSSLServerPort(sslPort);
setHyperionName(name);
}
@ -85,6 +87,14 @@ void SSDPHandler::handleSettingsUpdate(settings::type type, const QJsonDocument&
}
}
if(type == settings::PROTOSERVER)
{
if(obj["port"].toInt() != SSDPServer::getProtoBufPort())
{
SSDPServer::setProtoBufPort(obj["port"].toInt());
}
}
if(type == settings::JSONSERVER)
{
if(obj["port"].toInt() != SSDPServer::getJsonServerPort())
@ -93,6 +103,14 @@ void SSDPHandler::handleSettingsUpdate(settings::type type, const QJsonDocument&
}
}
if(type == settings::WEBSERVER)
{
if(obj["sslPort"].toInt() != SSDPServer::getSSLServerPort())
{
SSDPServer::setSSLServerPort(obj["sslPort"].toInt());
}
}
if (type == settings::GENERAL)
{
if (obj["name"].toString() != SSDPServer::getHyperionName())
@ -199,7 +217,21 @@ QString SSDPHandler::buildDesc() const
/// %2 friendly name Hyperion 2.0.0 (192.168.0.177)
/// %3 modelNumber 2.0.0
/// %4 serialNumber / UDN (H ID) Fjsa723dD0....
return SSDP_DESCRIPTION.arg(getBaseAddress(), QString("Hyperion (%1)").arg(_localAddress), QString(HYPERION_VERSION), _uuid);
/// %5 json port 19444
/// %6 ssl server port 8092
/// %7 protobuf port 19445
/// %8 flatbuf port 19400
return SSDP_DESCRIPTION.arg(
getBaseAddress(),
QString("Hyperion (%1)").arg(_localAddress),
QString(HYPERION_VERSION),
_uuid,
QString::number(SSDPServer::getJsonServerPort()),
QString::number(SSDPServer::getSSLServerPort()),
QString::number(SSDPServer::getProtoBufPort()),
QString::number(SSDPServer::getFlatBufPort())
);
}
void SSDPHandler::sendAnnounceList(bool alive)

View File

@ -153,7 +153,7 @@ void QtHttpClientWrapper::onClientDataReceived (void)
case RequestParsed: // a valid request has ben fully parsed
{
// Catch websocket header "Upgrade"
if(m_currentRequest->getHeader(QtHttpHeader::Upgrade) == "websocket")
if(m_currentRequest->getHeader(QtHttpHeader::Upgrade).toLower() == "websocket")
{
if(m_websocketClient == Q_NULLPTR)
{

View File

@ -302,7 +302,12 @@ void HyperionDaemon::startNetworkServices()
sslWsThread->start();
// Create SSDP server in thread
_ssdp = new SSDPHandler(_webserver, getSetting(settings::FLATBUFSERVER).object()["port"].toInt(), getSetting(settings::JSONSERVER).object()["port"].toInt(), getSetting(settings::GENERAL).object()["name"].toString());
_ssdp = new SSDPHandler(_webserver,
getSetting(settings::FLATBUFSERVER).object()["port"].toInt(),
getSetting(settings::PROTOSERVER).object()["port"].toInt(),
getSetting(settings::JSONSERVER).object()["port"].toInt(),
getSetting(settings::WEBSERVER).object()["sslPort"].toInt(),
getSetting(settings::GENERAL).object()["name"].toString());
QThread *ssdpThread = new QThread(this);
ssdpThread->setObjectName("SSDPThread");
_ssdp->moveToThread(ssdpThread);