mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 04:37:48 +02:00
Merge branch 'atp' of github.com:birarda/hifi into protocol
This commit is contained in:
commit
676e210791
6 changed files with 31 additions and 29 deletions
|
@ -288,7 +288,8 @@ void DomainServer::setupNodeListAndAssignments(const QUuid& sessionUUID) {
|
||||||
packetReceiver.registerListener(PacketType::NodeJsonStats, this, "processNodeJSONStatsPacket");
|
packetReceiver.registerListener(PacketType::NodeJsonStats, this, "processNodeJSONStatsPacket");
|
||||||
packetReceiver.registerListener(PacketType::ICEPing, this, "processICEPingPacket");
|
packetReceiver.registerListener(PacketType::ICEPing, this, "processICEPingPacket");
|
||||||
packetReceiver.registerListener(PacketType::ICEPingReply, this, "processICEPingReplyPacket");
|
packetReceiver.registerListener(PacketType::ICEPingReply, this, "processICEPingReplyPacket");
|
||||||
|
packetReceiver.registerListener(PacketType::ICEServerPeerInformation, this, "processICEPeerInformationPacket");
|
||||||
|
|
||||||
// add whatever static assignments that have been parsed to the queue
|
// add whatever static assignments that have been parsed to the queue
|
||||||
addStaticAssignmentsToQueue();
|
addStaticAssignmentsToQueue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,23 +46,26 @@ IceServer::IceServer(int argc, char* argv[]) :
|
||||||
|
|
||||||
void IceServer::processDatagrams() {
|
void IceServer::processDatagrams() {
|
||||||
HifiSockAddr sendingSockAddr;
|
HifiSockAddr sendingSockAddr;
|
||||||
QByteArray incomingPacket;
|
|
||||||
|
|
||||||
while (_serverSocket.hasPendingDatagrams()) {
|
while (_serverSocket.hasPendingDatagrams()) {
|
||||||
incomingPacket.resize(_serverSocket.pendingDatagramSize());
|
// setup a buffer to read the packet into
|
||||||
|
int packetSizeWithHeader = _serverSocket.pendingDatagramSize();
|
||||||
|
std::unique_ptr<char> buffer = std::unique_ptr<char>(new char[packetSizeWithHeader]);
|
||||||
|
|
||||||
_serverSocket.readDatagram(incomingPacket.data(), incomingPacket.size(),
|
_serverSocket.readDatagram(buffer.get(), packetSizeWithHeader,
|
||||||
sendingSockAddr.getAddressPointer(), sendingSockAddr.getPortPointer());
|
sendingSockAddr.getAddressPointer(), sendingSockAddr.getPortPointer());
|
||||||
|
|
||||||
|
auto packet = Packet::fromReceivedPacket(std::move(buffer), packetSizeWithHeader, sendingSockAddr);
|
||||||
|
|
||||||
PacketType::Value packetType = packetTypeForPacket(incomingPacket);
|
PacketType::Value packetType = packet->getType();
|
||||||
|
|
||||||
if (packetType == PacketType::ICEServerHeartbeat) {
|
if (packetType == PacketType::ICEServerHeartbeat) {
|
||||||
SharedNetworkPeer peer = addOrUpdateHeartbeatingPeer(incomingPacket);
|
SharedNetworkPeer peer = addOrUpdateHeartbeatingPeer(*packet);
|
||||||
|
|
||||||
// so that we can send packets to the heartbeating peer when we need, we need to activate a socket now
|
// so that we can send packets to the heartbeating peer when we need, we need to activate a socket now
|
||||||
peer->activateMatchingOrNewSymmetricSocket(sendingSockAddr);
|
peer->activateMatchingOrNewSymmetricSocket(sendingSockAddr);
|
||||||
} else if (packetType == PacketType::ICEServerQuery) {
|
} else if (packetType == PacketType::ICEServerQuery) {
|
||||||
QDataStream heartbeatStream(incomingPacket);
|
QDataStream heartbeatStream(packet.get());
|
||||||
|
|
||||||
// this is a node hoping to connect to a heartbeating peer - do we have the heartbeating peer?
|
// this is a node hoping to connect to a heartbeating peer - do we have the heartbeating peer?
|
||||||
QUuid senderUUID;
|
QUuid senderUUID;
|
||||||
|
@ -70,15 +73,12 @@ void IceServer::processDatagrams() {
|
||||||
|
|
||||||
// pull the public and private sock addrs for this peer
|
// pull the public and private sock addrs for this peer
|
||||||
HifiSockAddr publicSocket, localSocket;
|
HifiSockAddr publicSocket, localSocket;
|
||||||
|
|
||||||
heartbeatStream.skipRawData(numBytesForPacketHeader(incomingPacket));
|
|
||||||
|
|
||||||
heartbeatStream >> publicSocket >> localSocket;
|
heartbeatStream >> publicSocket >> localSocket;
|
||||||
|
|
||||||
// check if this node also included a UUID that they would like to connect to
|
// check if this node also included a UUID that they would like to connect to
|
||||||
QUuid connectRequestID;
|
QUuid connectRequestID;
|
||||||
heartbeatStream >> connectRequestID;
|
heartbeatStream >> connectRequestID;
|
||||||
|
|
||||||
SharedNetworkPeer matchingPeer = _activePeers.value(connectRequestID);
|
SharedNetworkPeer matchingPeer = _activePeers.value(connectRequestID);
|
||||||
|
|
||||||
if (matchingPeer) {
|
if (matchingPeer) {
|
||||||
|
@ -95,16 +95,16 @@ void IceServer::processDatagrams() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedNetworkPeer IceServer::addOrUpdateHeartbeatingPeer(const QByteArray& incomingPacket) {
|
SharedNetworkPeer IceServer::addOrUpdateHeartbeatingPeer(Packet& packet) {
|
||||||
QUuid senderUUID = uuidFromPacketHeader(incomingPacket);
|
|
||||||
|
|
||||||
// pull the public and private sock addrs for this peer
|
// pull the UUID, public and private sock addrs for this peer
|
||||||
|
QUuid senderUUID;
|
||||||
HifiSockAddr publicSocket, localSocket;
|
HifiSockAddr publicSocket, localSocket;
|
||||||
|
|
||||||
QDataStream hearbeatStream(incomingPacket);
|
QDataStream heartbeatStream(&packet);
|
||||||
hearbeatStream.skipRawData(numBytesForPacketHeader(incomingPacket));
|
|
||||||
|
heartbeatStream >> senderUUID;
|
||||||
hearbeatStream >> publicSocket >> localSocket;
|
heartbeatStream >> publicSocket >> localSocket;
|
||||||
|
|
||||||
// make sure we have this sender in our peer hash
|
// make sure we have this sender in our peer hash
|
||||||
SharedNetworkPeer matchingPeer = _activePeers.value(senderUUID);
|
SharedNetworkPeer matchingPeer = _activePeers.value(senderUUID);
|
||||||
|
@ -132,7 +132,7 @@ void IceServer::sendPeerInformationPacket(const NetworkPeer& peer, const HifiSoc
|
||||||
|
|
||||||
// get the byte array for this peer
|
// get the byte array for this peer
|
||||||
peerPacket->write(peer.toByteArray());
|
peerPacket->write(peer.toByteArray());
|
||||||
|
|
||||||
// write the current packet
|
// write the current packet
|
||||||
_serverSocket.writeDatagram(peerPacket->getData(), peerPacket->getDataSize(),
|
_serverSocket.writeDatagram(peerPacket->getData(), peerPacket->getDataSize(),
|
||||||
destinationSockAddr->getAddress(), destinationSockAddr->getPort());
|
destinationSockAddr->getAddress(), destinationSockAddr->getPort());
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <NetworkPeer.h>
|
#include <NetworkPeer.h>
|
||||||
#include <HTTPConnection.h>
|
#include <HTTPConnection.h>
|
||||||
#include <HTTPManager.h>
|
#include <HTTPManager.h>
|
||||||
|
#include <udt/Packet.h>
|
||||||
|
|
||||||
typedef QHash<QUuid, SharedNetworkPeer> NetworkPeerHash;
|
typedef QHash<QUuid, SharedNetworkPeer> NetworkPeerHash;
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ private slots:
|
||||||
void clearInactivePeers();
|
void clearInactivePeers();
|
||||||
private:
|
private:
|
||||||
|
|
||||||
SharedNetworkPeer addOrUpdateHeartbeatingPeer(const QByteArray& incomingPacket);
|
SharedNetworkPeer addOrUpdateHeartbeatingPeer(Packet& incomingPacket);
|
||||||
void sendPeerInformationPacket(const NetworkPeer& peer, const HifiSockAddr* destinationSockAddr);
|
void sendPeerInformationPacket(const NetworkPeer& peer, const HifiSockAddr* destinationSockAddr);
|
||||||
|
|
||||||
QUuid _id;
|
QUuid _id;
|
||||||
|
|
|
@ -136,7 +136,10 @@ void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname,
|
||||||
if (id != _uuid) {
|
if (id != _uuid) {
|
||||||
// re-set the domain info to connect to new domain
|
// re-set the domain info to connect to new domain
|
||||||
hardReset();
|
hardReset();
|
||||||
|
|
||||||
|
// refresh our ICE client UUID to something new
|
||||||
|
_iceClientID = QUuid::createUuid();
|
||||||
|
|
||||||
_iceDomainID = id;
|
_iceDomainID = id;
|
||||||
|
|
||||||
HifiSockAddr* replaceableSockAddr = &_iceServerSockAddr;
|
HifiSockAddr* replaceableSockAddr = &_iceServerSockAddr;
|
||||||
|
@ -154,10 +157,6 @@ void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname,
|
||||||
completedIceServerHostnameLookup();
|
completedIceServerHostnameLookup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// refresh our ICE client UUID to something new
|
|
||||||
_iceClientID = QUuid::createUuid();
|
|
||||||
|
|
||||||
qCDebug(networking) << "ICE required to connect to domain via ice server at" << iceServerHostname;
|
qCDebug(networking) << "ICE required to connect to domain via ice server at" << iceServerHostname;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -313,7 +312,8 @@ void DomainHandler::processDTLSRequirementPacket(QSharedPointer<NLPacket> dtlsRe
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainHandler::processICEResponsePacket(QSharedPointer<NLPacket> icePacket) {
|
void DomainHandler::processICEResponsePacket(QSharedPointer<NLPacket> icePacket) {
|
||||||
if (!_icePeer.hasSockets()) {
|
if (_icePeer.hasSockets()) {
|
||||||
|
qDebug() << "Received an ICE peer packet for domain-server but we already have sockets. Not processing.";
|
||||||
// bail on processing this packet if our ice peer doesn't have sockets
|
// bail on processing this packet if our ice peer doesn't have sockets
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -788,7 +788,7 @@ void LimitedNodeList::sendPacketToIceServer(PacketType::Value packetType, const
|
||||||
|
|
||||||
QDataStream iceDataStream(icePacket.get());
|
QDataStream iceDataStream(icePacket.get());
|
||||||
iceDataStream << clientID << _publicSockAddr << _localSockAddr;
|
iceDataStream << clientID << _publicSockAddr << _localSockAddr;
|
||||||
|
|
||||||
if (packetType == PacketType::ICEServerQuery) {
|
if (packetType == PacketType::ICEServerQuery) {
|
||||||
assert(!peerID.isNull());
|
assert(!peerID.isNull());
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,7 @@ void PacketReceiver::processDatagrams() {
|
||||||
|
|
||||||
// setup an NLPacket from the data we just read
|
// setup an NLPacket from the data we just read
|
||||||
auto packet = NLPacket::fromReceivedPacket(std::move(buffer), packetSizeWithHeader, senderSockAddr);
|
auto packet = NLPacket::fromReceivedPacket(std::move(buffer), packetSizeWithHeader, senderSockAddr);
|
||||||
|
|
||||||
_inPacketCount++;
|
_inPacketCount++;
|
||||||
_inByteCount += packetSizeWithHeader;
|
_inByteCount += packetSizeWithHeader;
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ void PacketReceiver::processDatagrams() {
|
||||||
_directConnectSetMutex.unlock();
|
_directConnectSetMutex.unlock();
|
||||||
|
|
||||||
PacketType::Value packetType = packet->getType();
|
PacketType::Value packetType = packet->getType();
|
||||||
|
|
||||||
if (matchingNode) {
|
if (matchingNode) {
|
||||||
// if this was a sequence numbered packet we should store the last seq number for
|
// if this was a sequence numbered packet we should store the last seq number for
|
||||||
// a packet of this type for this node
|
// a packet of this type for this node
|
||||||
|
|
Loading…
Reference in a new issue