From 303dfd7c1798f4aa211653d1bc66a9998cbe6ceb Mon Sep 17 00:00:00 2001 From: Manuel Schneider Date: Fri, 28 Nov 2014 14:54:54 +0100 Subject: Reset debug timeouts, fix autoconnect, remove magic numbers --- src/client/net/serverdiscovery.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/client/net/serverdiscovery.cpp') diff --git a/src/client/net/serverdiscovery.cpp b/src/client/net/serverdiscovery.cpp index 0062561..5dba327 100644 --- a/src/client/net/serverdiscovery.cpp +++ b/src/client/net/serverdiscovery.cpp @@ -10,7 +10,10 @@ /***************************************************************************//** * Ctor */ -ServerDiscovery::ServerDiscovery(QObject *parent) : QObject(parent) +ServerDiscovery::ServerDiscovery(QObject *parent) + : QObject(parent), + _minDiscoveryInterval(500), + _maxDiscoveryInterval(5000) { _hashErrorCount = 0; _ipErrorCount = 0; @@ -29,7 +32,7 @@ ServerDiscovery::ServerDiscovery(QObject *parent) : QObject(parent) connect(&_discoverySocket, SIGNAL(readyRead()), this, SLOT(onUdpReadyRead())); /* Setup the discovery timer */ - _discoveryTimer.setInterval(500); + _discoveryTimer.setInterval(_minDiscoveryInterval); _discoveryTimer.setSingleShot(true); // connect(&_discoveryTimer, SIGNAL(timeout()), this, SLOT(doDiscovery())); @@ -65,7 +68,7 @@ void ServerDiscovery::start(const QByteArray& sessionName, QString mgrIP) _hashErrorCount = _ipErrorCount = 0; // reset anbd start the discovery timer - _discoveryTimer.setInterval(500); + _discoveryTimer.setInterval(_minDiscoveryInterval); _discoveryTimer.start(); } @@ -131,7 +134,7 @@ void ServerDiscovery::doDiscovery() } // Start the timer again with a larger interval - if (_discoveryTimer.interval() < 5000) + if (_discoveryTimer.interval() < _maxDiscoveryInterval) _discoveryTimer.setInterval(_discoveryTimer.interval() * 2); _discoveryTimer.start(); } @@ -189,7 +192,7 @@ void ServerDiscovery::onUdpReadyRead() << addr.toString() + ":" + QString::fromUtf8(port) + "/" + _nameBytes; // Tell that a server hs been found - emit serverDetected(addr.toString(), (quint16)QString::fromUtf8(port).toInt(), _nameBytes, cert); + emit serverDetected(addr.toString(), (quint16)QString::fromUtf8(port).toInt(), _nameBytes, cert, (_mgrIP == addr)); // Stop the discovery this->stop(); -- cgit v1.2.3-55-g7522