Added avahi/bonjour advertisement to webconfig (#258)

This commit is contained in:
penfold42 2016-09-27 01:50:31 +10:00 committed by redPanther
parent d095b355b1
commit 6a26e4fd5f

View File

@ -8,6 +8,10 @@
#include <QFile> #include <QFile>
#include <QFileInfo> #include <QFileInfo>
#include <QResource> #include <QResource>
#include <QHostInfo>
#include <bonjour/bonjourserviceregister.h>
#include <bonjour/bonjourrecord.h>
StaticFileServing::StaticFileServing (Hyperion *hyperion, QString baseUrl, quint16 port, QObject * parent) StaticFileServing::StaticFileServing (Hyperion *hyperion, QString baseUrl, quint16 port, QObject * parent)
: QObject (parent) : QObject (parent)
@ -40,6 +44,18 @@ StaticFileServing::~StaticFileServing ()
void StaticFileServing::onServerStarted (quint16 port) void StaticFileServing::onServerStarted (quint16 port)
{ {
Info(_log, "started on port %d name \"%s\"", port ,_server->getServerName().toStdString().c_str()); Info(_log, "started on port %d name \"%s\"", port ,_server->getServerName().toStdString().c_str());
const std::string mDNSDescr = ( _server->getServerName().toStdString()
+ "@" +
QHostInfo::localHostName().toStdString()
);
BonjourServiceRegister *bonjourRegister_http = new BonjourServiceRegister();
bonjourRegister_http->registerService(
BonjourRecord(mDNSDescr.c_str(), "_http._tcp", QString()),
port
);
Debug(_log, "Web Config mDNS responder started");
} }
void StaticFileServing::onServerStopped () { void StaticFileServing::onServerStopped () {