Commit e5d3c6b3 authored by Kevin Whitaker's avatar Kevin Whitaker

Rearrange dnssd broadcast code to be more consistent and better fit class lifecycle.

parent 85766ffc
......@@ -79,18 +79,16 @@ signals:
SimpleCastTcpService::SimpleCastTcpService(MiniMediaPlayer *player,QObject *parent) : QTcpServer(parent),player(player),manager(new QNetworkAccessManager(this))
{
connect(manager,SIGNAL(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)),this,SLOT(networkAccessChanged(QNetworkAccessManager::NetworkAccessibility)));
dnsService = new KDNSSD::PublicService(QString(),"_simplecast._tcp",this->serverPort(),"local");
dnsService->setParent(this);
}
bool SimpleCastTcpService::listen(const QHostAddress& address, quint16 port)
{
bool listening = QTcpServer::listen(address,port);
//Setup DNSSD
dnsService = new KDNSSD::PublicService(QString(),"_simplecast._tcp",this->serverPort(),"local");
dnsService->setParent(this);
dnssdConnection = connect(manager,SIGNAL(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)),this,SLOT(networkAccessChanged(QNetworkAccessManager::NetworkAccessibility)));
//Start publishing now and if not, wait for networkAccessibleManager to let us know.
if(manager->networkAccessible() == QNetworkAccessManager::Accessible && !dnsService->isPublished())
if(manager->networkAccessible() == QNetworkAccessManager::Accessible)
{
dnsService->publishAsync();
}
......@@ -103,12 +101,17 @@ void SimpleCastTcpService::networkAccessChanged(QNetworkAccessManager::NetworkAc
{
dnsService->publishAsync();
}
else
{
dnsService->stop();
}
}
void SimpleCastTcpService::close()
{
QTcpServer::close();
disconnect(dnssdConnection);
dnsService->stop();
}
......
......@@ -45,6 +45,7 @@ private:
MiniMediaPlayer *player;
KDNSSD::PublicService *dnsService;
QNetworkAccessManager *manager;
QMetaObject::Connection dnssdConnection;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment