summaryrefslogtreecommitdiffstats
path: root/src/client/net/serverdiscovery.cpp
diff options
context:
space:
mode:
authorBjörn Hagemeister2014-08-25 18:08:15 +0200
committerBjörn Hagemeister2014-08-25 18:08:15 +0200
commit6cb63e7e30906f428c601ba00fd15c14e07093cf (patch)
treef83ea27e10616a384c26480e662854cf02ac8834 /src/client/net/serverdiscovery.cpp
parentNew Feature: Button for reloading room configuration of choosable room. (diff)
downloadpvs2-6cb63e7e30906f428c601ba00fd15c14e07093cf.tar.gz
pvs2-6cb63e7e30906f428c601ba00fd15c14e07093cf.tar.xz
pvs2-6cb63e7e30906f428c601ba00fd15c14e07093cf.zip
Client is able to auto - connect to the same room belonging manager.
Diffstat (limited to 'src/client/net/serverdiscovery.cpp')
-rw-r--r--src/client/net/serverdiscovery.cpp36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/client/net/serverdiscovery.cpp b/src/client/net/serverdiscovery.cpp
index a4edb46..2cd0796 100644
--- a/src/client/net/serverdiscovery.cpp
+++ b/src/client/net/serverdiscovery.cpp
@@ -45,8 +45,14 @@ ServerDiscovery::~ServerDiscovery()
/***************************************************************************//**
* @brief start
*/
-void ServerDiscovery::start(const QByteArray& sessionName)
+void ServerDiscovery::start(const QByteArray& sessionName, QString mgrIP)
{
+ if (mgrIP != NULL) {
+ _mgrIP.setAddress(mgrIP);
+ } else {
+ _mgrIP = NULL;
+ }
+
//assert(!this->isActive());
// Set the session which is searched
@@ -98,21 +104,31 @@ void ServerDiscovery::doDiscovery()
_packet.setField(_SALT1, salt1);
_packet.setField(_SALT2, _salt2);
_packet.setField(_IPLIST, iplist);
- foreach (QNetworkInterface interface, QNetworkInterface::allInterfaces())
+
+ // Check if specifig manager IP is given. If not broadcast in whole network.
+ if (_mgrIP != QHostAddress::Null)
+ {
+ qDebug() << "Broadcasting to " << _mgrIP.toString();
+ if (!_packet.writeMessage(&_discoverySocket, _mgrIP, SERVICE_DISCOVERY_PORT))
+ qDebug("Failed");
+ } else
{
- foreach (QNetworkAddressEntry entry, interface.addressEntries())
+ foreach (QNetworkInterface interface, QNetworkInterface::allInterfaces())
{
- if (!entry.broadcast().isNull() && entry.ip() != QHostAddress::LocalHost && entry.ip() != QHostAddress::LocalHostIPv6)
+ foreach (QNetworkAddressEntry entry, interface.addressEntries())
{
- qDebug() << "Broadcasting to " << entry.broadcast().toString();
- if (!_packet.writeMessage(&_discoverySocket, entry.broadcast(), SERVICE_DISCOVERY_PORT))
- qDebug("FAILED");
+ if (!entry.broadcast().isNull() && entry.ip() != QHostAddress::LocalHost && entry.ip() != QHostAddress::LocalHostIPv6)
+ {
+ qDebug() << "Broadcasting to " << entry.broadcast().toString();
+ if (!_packet.writeMessage(&_discoverySocket, entry.broadcast(), SERVICE_DISCOVERY_PORT))
+ qDebug("FAILED");
+ }
}
}
+ qDebug("Broadcasting to 255.255.255.255");
+ if (!_packet.writeMessage(&_discoverySocket, QHostAddress::Broadcast, SERVICE_DISCOVERY_PORT))
+ qDebug("FAILED");
}
- qDebug("Broadcasting to 255.255.255.255");
- if (!_packet.writeMessage(&_discoverySocket, QHostAddress::Broadcast, SERVICE_DISCOVERY_PORT))
- qDebug("FAILED");
// Start the timer again with a larger interval
if (_discoveryTimer.interval() < 5000)