PeerManager::PeerManager (Client *client) : QObject (client) { this->client = client; updateAddresses(); f_serverPort = 0; m_serverPort = 0; broadcastSocket.bind (QHostAddress::Any, broadcastPort, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); broadcastTimer.setInterval (BroadcastInterval); connect (&broadcastSocket, SIGNAL (readyRead()), this, SLOT (readBroadcastDatagram())); connect ( &broadcastTimer, SIGNAL (timeout()), this, SLOT (sendBroadcastDatagram())); }
PeerManager::PeerManager(QString userName, Client *client) : QObject(client) { this->client = client; this->username = userName.toUtf8(); if (username.isEmpty()) username = "******"; updateAddresses(); serverPort = 0; broadcastSocket.bind(QHostAddress::AnyIPv4, broadcastPort, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); connect(&broadcastSocket, SIGNAL(readyRead()), this, SLOT(readBroadcastDatagram())); broadcastTimer.setInterval(BroadcastInterval); connect(&broadcastTimer, SIGNAL(timeout()), this, SLOT(sendBroadcastDatagram())); }