Commit 8041e1a8 authored by Kevin Whitaker's avatar Kevin Whitaker

Fix oops where I set the broadcast port to 0 by setting early. Rearrange tcp...

Fix oops where I set the broadcast port to 0 by setting early. Rearrange tcp server code to be in sync with broadcasting code.
parent e5d3c6b3
......@@ -79,12 +79,15 @@ signals:
SimpleCastTcpService::SimpleCastTcpService(MiniMediaPlayer *player,QObject *parent) : QTcpServer(parent),player(player),manager(new QNetworkAccessManager(this))
{
dnsService = new KDNSSD::PublicService(QString(),"_simplecast._tcp",this->serverPort(),"local");
dnsService = new KDNSSD::PublicService(QString(),"_simplecast._tcp",port,"local");
dnsService->setParent(this);
}
bool SimpleCastTcpService::listen(const QHostAddress& address, quint16 port)
{
this->address = address;
this->port = port;
dnsService->setPort(port);
bool listening = QTcpServer::listen(address,port);
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.
......@@ -99,10 +102,12 @@ void SimpleCastTcpService::networkAccessChanged(QNetworkAccessManager::NetworkAc
{
if(accessible == QNetworkAccessManager::Accessible)
{
QTcpServer::listen(address,port);
dnsService->publishAsync();
}
else
{
QTcpServer::close();
dnsService->stop();
}
......@@ -110,8 +115,8 @@ void SimpleCastTcpService::networkAccessChanged(QNetworkAccessManager::NetworkAc
void SimpleCastTcpService::close()
{
QTcpServer::close();
disconnect(dnssdConnection);
QTcpServer::close();
dnsService->stop();
}
......
......@@ -46,6 +46,8 @@ private:
KDNSSD::PublicService *dnsService;
QNetworkAccessManager *manager;
QMetaObject::Connection dnssdConnection;
QHostAddress address = QHostAddress::Any;
quint64 port = 54634;
};
......
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