mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Feat: SSDP discovery for hyperion-remote (#602)
* Auto stash before merge of "log" and "hyperion-project/master" * resolve merge tool mess
This commit is contained in:
@@ -36,7 +36,7 @@ void SSDPDiscover::searchForService(const QString& st)
|
||||
|
||||
const QString SSDPDiscover::getFirstService(const searchType& type, const QString& st, const int& timeout_ms)
|
||||
{
|
||||
Info(_log, "Search for Service [%s]", QSTRING_CSTR(st));
|
||||
Info(_log, "Search for Hyperion server");
|
||||
_searchTarget = st;
|
||||
|
||||
// search
|
||||
@@ -91,7 +91,7 @@ const QString SSDPDiscover::getFirstService(const searchType& type, const QStrin
|
||||
//Info(_log, "Received msearch response from '%s:%d'. Search target: %s",QSTRING_CSTR(sender.toString()), senderPort, QSTRING_CSTR(headers.value("st")));
|
||||
if(type == STY_WEBSERVER)
|
||||
{
|
||||
Info(_log, "Found service [%s] at: %s:%d", QSTRING_CSTR(st), QSTRING_CSTR(url.host()), url.port());
|
||||
Info(_log, "Found service at: %s:%d", QSTRING_CSTR(url.host()), url.port());
|
||||
|
||||
return url.host()+":"+QString::number(url.port());
|
||||
}
|
||||
@@ -104,10 +104,23 @@ const QString SSDPDiscover::getFirstService(const searchType& type, const QStrin
|
||||
}
|
||||
else
|
||||
{
|
||||
Info(_log, "Found service [%s] at: %s:%s", QSTRING_CSTR(st), QSTRING_CSTR(url.host()), QSTRING_CSTR(fbsport));
|
||||
Info(_log, "Found service at: %s:%s", QSTRING_CSTR(url.host()), QSTRING_CSTR(fbsport));
|
||||
return url.host()+":"+fbsport;
|
||||
}
|
||||
}
|
||||
else if(type == STY_JSONSERVER)
|
||||
{
|
||||
const QString jssport = headers.value("hyperion-jss-port");
|
||||
if(jssport.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info(_log, "Found service at: %s:%s", QSTRING_CSTR(url.host()), QSTRING_CSTR(jssport));
|
||||
return url.host()+":"+jssport;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Info(_log,"Search timeout, service [%s] not found", QSTRING_CSTR(st) );
|
||||
|
@@ -9,14 +9,14 @@
|
||||
#include <QNetworkInterface>
|
||||
#include <QNetworkConfigurationManager>
|
||||
|
||||
SSDPHandler::SSDPHandler(WebServer* webserver, const quint16& flatBufPort, QObject * parent)
|
||||
SSDPHandler::SSDPHandler(WebServer* webserver, const quint16& flatBufPort, const quint16& jsonServerPort, QObject * parent)
|
||||
: SSDPServer(parent)
|
||||
, _webserver(webserver)
|
||||
, _localAddress()
|
||||
, _NCA(nullptr)
|
||||
{
|
||||
_flatbufPort = flatBufPort;
|
||||
setFlatBufPort(_flatbufPort);
|
||||
setFlatBufPort(flatBufPort);
|
||||
setJsonServerPort(jsonServerPort);
|
||||
}
|
||||
|
||||
SSDPHandler::~SSDPHandler()
|
||||
@@ -62,10 +62,18 @@ void SSDPHandler::handleSettingsUpdate(const settings::type& type, const QJsonDo
|
||||
if(type == settings::FLATBUFSERVER)
|
||||
{
|
||||
const QJsonObject& obj = config.object();
|
||||
if(obj["port"].toInt() != _flatbufPort)
|
||||
if(obj["port"].toInt() != SSDPServer::getFlatBufPort())
|
||||
{
|
||||
_flatbufPort = obj["port"].toInt();
|
||||
setFlatBufPort(_flatbufPort);
|
||||
SSDPServer::setFlatBufPort(obj["port"].toInt());
|
||||
}
|
||||
}
|
||||
|
||||
if(type == settings::JSONSERVER)
|
||||
{
|
||||
const QJsonObject& obj = config.object();
|
||||
if(obj["port"].toInt() != SSDPServer::getJsonServerPort())
|
||||
{
|
||||
SSDPServer::setJsonServerPort(obj["port"].toInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ static const QString UPNP_ALIVE_MESSAGE = "NOTIFY * HTTP/1.1\r\n"
|
||||
"SERVER: %4\r\n"
|
||||
"USN: uuid:%5\r\n"
|
||||
"HYPERION-FBS-PORT: %6\r\n"
|
||||
"HYPERION-JSS-PORT: %7\r\n"
|
||||
"\r\n";
|
||||
|
||||
// Implement ssdp:update as per spec 1.1, section 1.2.4
|
||||
@@ -70,6 +71,7 @@ static const QString UPNP_MSEARCH_RESPONSE = "HTTP/1.1 200 OK\r\n"
|
||||
"ST: %5\r\n"
|
||||
"USN: uuid:%6\r\n"
|
||||
"HYPERION-FBS-PORT: %7\r\n"
|
||||
"HYPERION-JSS-PORT: %8\r\n"
|
||||
"\r\n";
|
||||
|
||||
SSDPServer::SSDPServer(QObject * parent)
|
||||
@@ -169,7 +171,8 @@ void SSDPServer::sendMSearchResponse(const QString& st, const QString& senderIp,
|
||||
, _serverHeader
|
||||
, st
|
||||
, _uuid
|
||||
, _fbsPort );
|
||||
, _fbsPort
|
||||
, _jssPort );
|
||||
|
||||
_udpSocket->writeDatagram(message.toUtf8(),
|
||||
QHostAddress(senderIp),
|
||||
@@ -199,7 +202,8 @@ void SSDPServer::sendAlive(const QString& st)
|
||||
, st
|
||||
, _serverHeader
|
||||
, tempUSN
|
||||
, _fbsPort);
|
||||
, _fbsPort
|
||||
, _jssPort );
|
||||
|
||||
// we repeat 3 times
|
||||
quint8 rep = 0;
|
||||
|
Reference in New Issue
Block a user