diff options
| author | Manuel Schneider | 2014-09-03 15:40:39 +0200 |
|---|---|---|
| committer | Manuel Schneider | 2014-09-03 15:40:39 +0200 |
| commit | 6017ad54c22bcb991c832f90d2a19722198886bb (patch) | |
| tree | 384bbf35357aba506d2bae131abc4747b8c30af0 /src/client/net | |
| parent | Change system settings path. Change name of config file (diff) | |
| parent | Added german translations for client. (diff) | |
| download | pvs2-6017ad54c22bcb991c832f90d2a19722198886bb.tar.gz pvs2-6017ad54c22bcb991c832f90d2a19722198886bb.tar.xz pvs2-6017ad54c22bcb991c832f90d2a19722198886bb.zip | |
Merge branch 'master' of git.openslx.org:pvs2
Diffstat (limited to 'src/client/net')
| -rw-r--r-- | src/client/net/serverconnection.cpp | 2 | ||||
| -rw-r--r-- | src/client/net/serverdiscovery.cpp | 36 | ||||
| -rw-r--r-- | src/client/net/serverdiscovery.h | 4 |
3 files changed, 30 insertions, 12 deletions
diff --git a/src/client/net/serverconnection.cpp b/src/client/net/serverconnection.cpp index babd64f..7954c34 100644 --- a/src/client/net/serverconnection.cpp +++ b/src/client/net/serverconnection.cpp @@ -26,7 +26,7 @@ ServerConnection::ServerConnection(const QString& host, const quint16 port, cons connect(_socket, SIGNAL(encrypted()), this, SLOT(sock_connected())); connect(_socket, SIGNAL(readyRead()), this, SLOT(sock_dataArrival())); connect(_socket, SIGNAL(disconnected()), this, SLOT(sock_closed())); - connect(_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(sock_error(QAbstractSocket::SocketError))); + connect(_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(sock_error(QAbstractSocket::SocketError))); connect(_socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, 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) diff --git a/src/client/net/serverdiscovery.h b/src/client/net/serverdiscovery.h index 093b841..fee9fd0 100644 --- a/src/client/net/serverdiscovery.h +++ b/src/client/net/serverdiscovery.h @@ -19,7 +19,7 @@ class ServerDiscovery : public QObject explicit ServerDiscovery(QObject *parent = 0); ~ServerDiscovery(); - void start(const QByteArray& sessionName); + void start(const QByteArray& sessionName, QString mgrIP); void stop(); inline bool isActive(){ return _discoveryTimer.isActive(); } @@ -32,6 +32,8 @@ class ServerDiscovery : public QObject QUdpSocket _discoverySocket; NetworkMessage _packet; + QHostAddress _mgrIP; + static const int UDPBUFSIZ = 9000; static const int SALT_LEN = 18; |
