mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 04:12:46 +02:00
ping connecting ICE peers from domain-server
This commit is contained in:
parent
63877b0756
commit
0d4ef4aaca
3 changed files with 57 additions and 1 deletions
|
@ -354,7 +354,7 @@ void DomainServer::setupAutomaticNetworking() {
|
||||||
|
|
||||||
// setup a timer to heartbeat with the ice-server every so often
|
// setup a timer to heartbeat with the ice-server every so often
|
||||||
QTimer* iceHeartbeatTimer = new QTimer(this);
|
QTimer* iceHeartbeatTimer = new QTimer(this);
|
||||||
connect(iceHeartbeatTimer, &QTimer::timeout, this, &DomainServer::sendHearbeatToIceServer);
|
connect(iceHeartbeatTimer, &QTimer::timeout, this, &DomainServer::performICEUpdates);
|
||||||
iceHeartbeatTimer->start(ICE_HEARBEAT_INTERVAL_MSECS);
|
iceHeartbeatTimer->start(ICE_HEARBEAT_INTERVAL_MSECS);
|
||||||
|
|
||||||
// call our sendHeartbeaToIceServer immediately anytime a public address changes
|
// call our sendHeartbeaToIceServer immediately anytime a public address changes
|
||||||
|
@ -985,10 +985,51 @@ void DomainServer::updateNetworkingInfoWithDataServer(const QString& newSetting,
|
||||||
|
|
||||||
const HifiSockAddr ICE_SERVER_SOCK_ADDR = HifiSockAddr(QHostAddress::LocalHost, ICE_SERVER_DEFAULT_PORT);
|
const HifiSockAddr ICE_SERVER_SOCK_ADDR = HifiSockAddr(QHostAddress::LocalHost, ICE_SERVER_DEFAULT_PORT);
|
||||||
|
|
||||||
|
void DomainServer::performICEUpdates() {
|
||||||
|
sendHearbeatToIceServer();
|
||||||
|
sendICEPingPackets();
|
||||||
|
}
|
||||||
|
|
||||||
void DomainServer::sendHearbeatToIceServer() {
|
void DomainServer::sendHearbeatToIceServer() {
|
||||||
LimitedNodeList::getInstance()->sendHeartbeatToIceServer(ICE_SERVER_SOCK_ADDR);
|
LimitedNodeList::getInstance()->sendHeartbeatToIceServer(ICE_SERVER_SOCK_ADDR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DomainServer::sendICEPingPackets() {
|
||||||
|
LimitedNodeList* nodeList = LimitedNodeList::getInstance();
|
||||||
|
|
||||||
|
foreach(const NetworkPeer& peer, _connectingICEPeers) {
|
||||||
|
// send ping packets to this peer's interfaces
|
||||||
|
qDebug() << "Sending ping packets to establish connectivity with ICE peer with ID"
|
||||||
|
<< peer.getUUID();
|
||||||
|
|
||||||
|
// send the ping packet to the local and public sockets for this node
|
||||||
|
QByteArray localPingPacket = nodeList->constructPingPacket(PingType::Local, false);
|
||||||
|
nodeList->writeUnverifiedDatagram(localPingPacket, peer.getLocalSocket());
|
||||||
|
|
||||||
|
QByteArray publicPingPacket = nodeList->constructPingPacket(PingType::Public, false);
|
||||||
|
nodeList->writeUnverifiedDatagram(publicPingPacket, peer.getPublicSocket());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DomainServer::processICEHeartbeatResponse(const QByteArray& packet) {
|
||||||
|
// loop through the packet and pull out network peers
|
||||||
|
// any peer we don't have we add to the hash, otherwise we update
|
||||||
|
QDataStream iceResponseStream(packet);
|
||||||
|
iceResponseStream.skipRawData(numBytesForPacketHeader(packet));
|
||||||
|
|
||||||
|
NetworkPeer receivedPeer;
|
||||||
|
|
||||||
|
while (!iceResponseStream.atEnd()) {
|
||||||
|
iceResponseStream >> receivedPeer;
|
||||||
|
|
||||||
|
if (!_connectingICEPeers.contains(receivedPeer.getUUID())) {
|
||||||
|
qDebug() << "New peer requesting connection being added to hash -" << receivedPeer;
|
||||||
|
}
|
||||||
|
|
||||||
|
_connectingICEPeers[receivedPeer.getUUID()] = receivedPeer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DomainServer::processDatagram(const QByteArray& receivedPacket, const HifiSockAddr& senderSockAddr) {
|
void DomainServer::processDatagram(const QByteArray& receivedPacket, const HifiSockAddr& senderSockAddr) {
|
||||||
LimitedNodeList* nodeList = LimitedNodeList::getInstance();
|
LimitedNodeList* nodeList = LimitedNodeList::getInstance();
|
||||||
|
|
||||||
|
@ -1036,6 +1077,9 @@ void DomainServer::processDatagram(const QByteArray& receivedPacket, const HifiS
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case PacketTypeIceServerHeartbeatResponse:
|
||||||
|
processICEHeartbeatResponse(receivedPacket);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,9 @@ private slots:
|
||||||
|
|
||||||
void requestCurrentPublicSocketViaSTUN();
|
void requestCurrentPublicSocketViaSTUN();
|
||||||
void performIPAddressUpdate(const HifiSockAddr& newPublicSockAddr);
|
void performIPAddressUpdate(const HifiSockAddr& newPublicSockAddr);
|
||||||
|
void performICEUpdates();
|
||||||
void sendHearbeatToIceServer();
|
void sendHearbeatToIceServer();
|
||||||
|
void sendICEPingPackets();
|
||||||
private:
|
private:
|
||||||
void setupNodeListAndAssignments(const QUuid& sessionUUID = QUuid::createUuid());
|
void setupNodeListAndAssignments(const QUuid& sessionUUID = QUuid::createUuid());
|
||||||
bool optionallySetupOAuth();
|
bool optionallySetupOAuth();
|
||||||
|
@ -74,6 +76,7 @@ private:
|
||||||
|
|
||||||
void setupAutomaticNetworking();
|
void setupAutomaticNetworking();
|
||||||
void updateNetworkingInfoWithDataServer(const QString& newSetting, const QString& networkAddress = QString());
|
void updateNetworkingInfoWithDataServer(const QString& newSetting, const QString& networkAddress = QString());
|
||||||
|
void processICEHeartbeatResponse(const QByteArray& packet);
|
||||||
|
|
||||||
void processDatagram(const QByteArray& receivedPacket, const HifiSockAddr& senderSockAddr);
|
void processDatagram(const QByteArray& receivedPacket, const HifiSockAddr& senderSockAddr);
|
||||||
|
|
||||||
|
@ -135,6 +138,9 @@ private:
|
||||||
|
|
||||||
HifiSockAddr _localSockAddr;
|
HifiSockAddr _localSockAddr;
|
||||||
|
|
||||||
|
QHash<QUuid, NetworkPeer> _connectingICEPeers;
|
||||||
|
QHash<QUuid, HifiSockAddr> _connectedICEPeers;
|
||||||
|
|
||||||
DomainServerSettingsManager _settingsManager;
|
DomainServerSettingsManager _settingsManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,12 @@ void NodeList::processNodeData(const HifiSockAddr& senderSockAddr, const QByteAr
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case PacketTypeUnverifiedPing: {
|
||||||
|
// send back a reply
|
||||||
|
QByteArray replyPacket = constructPingReplyPacket(packet);
|
||||||
|
writeUnverifiedDatagram(replyPacket, senderSockAddr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case PacketTypeUnverifiedPingReply: {
|
case PacketTypeUnverifiedPingReply: {
|
||||||
qDebug() << "Received reply from domain-server on" << senderSockAddr;
|
qDebug() << "Received reply from domain-server on" << senderSockAddr;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue