mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 03:19:24 +02:00
use new networking in sendPacketToIceServer
This commit is contained in:
parent
402f7dc075
commit
e7e489af61
3 changed files with 15 additions and 15 deletions
|
@ -62,21 +62,22 @@ void IceServer::processDatagrams() {
|
||||||
// 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 == PacketTypeIceServerQuery) {
|
} else if (packetType == PacketTypeIceServerQuery) {
|
||||||
|
QDataStream heartbeatStream(incomingPacket);
|
||||||
|
|
||||||
// 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 = uuidFromPacketHeader(incomingPacket);
|
QUuid senderUUID;
|
||||||
|
heartbeatStream >> senderUUID;
|
||||||
|
|
||||||
// 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;
|
||||||
|
|
||||||
QDataStream hearbeatStream(incomingPacket);
|
heartbeatStream.skipRawData(numBytesForPacketHeader(incomingPacket));
|
||||||
hearbeatStream.skipRawData(numBytesForPacketHeader(incomingPacket));
|
|
||||||
|
|
||||||
hearbeatStream >> 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;
|
||||||
hearbeatStream >> connectRequestID;
|
heartbeatStream >> connectRequestID;
|
||||||
|
|
||||||
SharedNetworkPeer matchingPeer = _activePeers.value(connectRequestID);
|
SharedNetworkPeer matchingPeer = _activePeers.value(connectRequestID);
|
||||||
|
|
||||||
|
|
|
@ -848,23 +848,22 @@ void LimitedNodeList::updateLocalSockAddr() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LimitedNodeList::sendHeartbeatToIceServer(const HifiSockAddr& iceServerSockAddr) {
|
void LimitedNodeList::sendHeartbeatToIceServer(const HifiSockAddr& iceServerSockAddr) {
|
||||||
sendPacketToIceServer(PacketTypeIceServerHeartbeat, iceServerSockAddr, _sessionUUID);
|
sendPacketToIceServer(PacketType::ICEServerHeartbeat, iceServerSockAddr, _sessionUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LimitedNodeList::sendPeerQueryToIceServer(const HifiSockAddr& iceServerSockAddr, const QUuid& clientID,
|
void LimitedNodeList::sendPeerQueryToIceServer(const HifiSockAddr& iceServerSockAddr, const QUuid& clientID,
|
||||||
const QUuid& peerID) {
|
const QUuid& peerID) {
|
||||||
sendPacketToIceServer(PacketTypeIceServerQuery, iceServerSockAddr, clientID, peerID);
|
sendPacketToIceServer(PacketType::ICEServerQuery, iceServerSockAddr, clientID, peerID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LimitedNodeList::sendPacketToIceServer(PacketType::Value packetType, const HifiSockAddr& iceServerSockAddr,
|
void LimitedNodeList::sendPacketToIceServer(PacketType::Value packetType, const HifiSockAddr& iceServerSockAddr,
|
||||||
const QUuid& headerID, const QUuid& peerID) {
|
const QUuid& clientID, const QUuid& peerID) {
|
||||||
|
auto icePacket = Packet::create(packetType);
|
||||||
|
|
||||||
QByteArray iceRequestByteArray = byteArrayWithUUIDPopulatedHeader(packetType, headerID);
|
QDataStream iceDataStream(icePacket.get());
|
||||||
QDataStream iceDataStream(&iceRequestByteArray, QIODevice::Append);
|
iceDataStream << clientID << _publicSockAddr << _localSockAddr;
|
||||||
|
|
||||||
iceDataStream << _publicSockAddr << _localSockAddr;
|
if (packetType == PacketType::ICEServerQuery) {
|
||||||
|
|
||||||
if (packetType == PacketTypeIceServerQuery) {
|
|
||||||
assert(!peerID.isNull());
|
assert(!peerID.isNull());
|
||||||
|
|
||||||
iceDataStream << peerID;
|
iceDataStream << peerID;
|
||||||
|
@ -873,7 +872,7 @@ void LimitedNodeList::sendPacketToIceServer(PacketType::Value packetType, const
|
||||||
<< uuidStringWithoutCurlyBraces(peerID);
|
<< uuidStringWithoutCurlyBraces(peerID);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeUnverifiedDatagram(iceRequestByteArray, iceServerSockAddr);
|
sendPacket(icePacket, iceServerSockAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LimitedNodeList::putLocalPortIntoSharedMemory(const QString key, QObject* parent, quint16 localPort) {
|
void LimitedNodeList::putLocalPortIntoSharedMemory(const QString key, QObject* parent, quint16 localPort) {
|
||||||
|
|
|
@ -287,7 +287,7 @@ protected:
|
||||||
|
|
||||||
void stopInitialSTUNUpdate(bool success);
|
void stopInitialSTUNUpdate(bool success);
|
||||||
|
|
||||||
void sendPacketToIceServer(PacketType::Value packetType, const HifiSockAddr& iceServerSockAddr, const QUuid& headerID,
|
void sendPacketToIceServer(PacketType::Value packetType, const HifiSockAddr& iceServerSockAddr, const QUuid& clientID,
|
||||||
const QUuid& peerRequestID = QUuid());
|
const QUuid& peerRequestID = QUuid());
|
||||||
|
|
||||||
QUuid _sessionUUID;
|
QUuid _sessionUUID;
|
||||||
|
|
Loading…
Reference in a new issue