mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 08:48:43 +02:00
Local node IDs now working correctly
Move typedef to single location; fixes for replicated packets (probably still not correct); reserve zero as local ID; pass domain server's local ID in domain server list; other tweaks.
This commit is contained in:
parent
d3464378b7
commit
bed4033554
10 changed files with 23 additions and 23 deletions
|
@ -117,16 +117,13 @@ void AudioMixer::queueAudioPacket(QSharedPointer<ReceivedMessage> message, Share
|
||||||
void AudioMixer::queueReplicatedAudioPacket(QSharedPointer<ReceivedMessage> message) {
|
void AudioMixer::queueReplicatedAudioPacket(QSharedPointer<ReceivedMessage> message) {
|
||||||
// make sure we have a replicated node for the original sender of the packet
|
// make sure we have a replicated node for the original sender of the packet
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
|
||||||
QUuid nodeID;
|
// Node ID is now part of user data, since replicated audio packets are non-sourced.
|
||||||
SharedNodePointer sourceNode = nodeList->nodeWithLocalID(message->getSourceID());
|
QUuid nodeID = QUuid::fromRfc4122(message->readWithoutCopy(NUM_BYTES_RFC4122_UUID));
|
||||||
if (sourceNode) {
|
|
||||||
nodeID = sourceNode->getUUID();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto replicatedNode = nodeList->addOrUpdateNode(nodeID, NodeType::Agent,
|
auto replicatedNode = nodeList->addOrUpdateNode(nodeID, NodeType::Agent,
|
||||||
message->getSenderSockAddr(), message->getSenderSockAddr(),
|
message->getSenderSockAddr(), message->getSenderSockAddr(),
|
||||||
true, true);
|
0, true, true);
|
||||||
replicatedNode->setLastHeardMicrostamp(usecTimestampNow());
|
replicatedNode->setLastHeardMicrostamp(usecTimestampNow());
|
||||||
|
|
||||||
// construct a "fake" audio received message from the byte array and packet list information
|
// construct a "fake" audio received message from the byte array and packet list information
|
||||||
|
@ -140,7 +137,7 @@ void AudioMixer::queueReplicatedAudioPacket(QSharedPointer<ReceivedMessage> mess
|
||||||
|
|
||||||
auto replicatedMessage = QSharedPointer<ReceivedMessage>::create(audioData, rewrittenType,
|
auto replicatedMessage = QSharedPointer<ReceivedMessage>::create(audioData, rewrittenType,
|
||||||
versionForPacketType(rewrittenType),
|
versionForPacketType(rewrittenType),
|
||||||
message->getSenderSockAddr(), message->getSourceID());
|
message->getSenderSockAddr(), nodeList->getSessionLocalID());
|
||||||
|
|
||||||
getOrCreateClientData(replicatedNode.data())->queuePacket(replicatedMessage, replicatedNode);
|
getOrCreateClientData(replicatedNode.data())->queuePacket(replicatedMessage, replicatedNode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ SharedNodePointer addOrUpdateReplicatedNode(const QUuid& nodeID, const HifiSockA
|
||||||
auto replicatedNode = DependencyManager::get<NodeList>()->addOrUpdateNode(nodeID, NodeType::Agent,
|
auto replicatedNode = DependencyManager::get<NodeList>()->addOrUpdateNode(nodeID, NodeType::Agent,
|
||||||
senderSockAddr,
|
senderSockAddr,
|
||||||
senderSockAddr,
|
senderSockAddr,
|
||||||
true, true);
|
0, true, true);
|
||||||
|
|
||||||
replicatedNode->setLastHeardMicrostamp(usecTimestampNow());
|
replicatedNode->setLastHeardMicrostamp(usecTimestampNow());
|
||||||
|
|
||||||
|
@ -112,12 +112,8 @@ void AvatarMixer::handleReplicatedPacket(QSharedPointer<ReceivedMessage> message
|
||||||
void AvatarMixer::handleReplicatedBulkAvatarPacket(QSharedPointer<ReceivedMessage> message) {
|
void AvatarMixer::handleReplicatedBulkAvatarPacket(QSharedPointer<ReceivedMessage> message) {
|
||||||
while (message->getBytesLeftToRead()) {
|
while (message->getBytesLeftToRead()) {
|
||||||
// first, grab the node ID for this replicated avatar
|
// first, grab the node ID for this replicated avatar
|
||||||
QUuid nodeID;
|
// Node ID is now part of user data, since ReplicatedBulkAvatarPacket is non-sourced.
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeID = QUuid::fromRfc4122(message->readWithoutCopy(NUM_BYTES_RFC4122_UUID));
|
||||||
SharedNodePointer sourceNode = nodeList->nodeWithLocalID(message->getSourceID());
|
|
||||||
if (sourceNode) {
|
|
||||||
nodeID = sourceNode->getUUID();
|
|
||||||
}
|
|
||||||
// make sure we have an upstream replicated node that matches
|
// make sure we have an upstream replicated node that matches
|
||||||
auto replicatedNode = addOrUpdateReplicatedNode(nodeID, message->getSenderSockAddr());
|
auto replicatedNode = addOrUpdateReplicatedNode(nodeID, message->getSenderSockAddr());
|
||||||
|
|
||||||
|
|
|
@ -1037,7 +1037,7 @@ Node::LocalID DomainGatekeeper::findOrCreateLocalID(const QUuid& uuid) {
|
||||||
do {
|
do {
|
||||||
newLocalID = _currentLocalID;
|
newLocalID = _currentLocalID;
|
||||||
_currentLocalID += _idIncrement;
|
_currentLocalID += _idIncrement;
|
||||||
} while (_localIDToUUID.find(newLocalID) != _localIDToUUID.end());
|
} while (newLocalID == 0 || _localIDToUUID.find(newLocalID) != _localIDToUUID.end());
|
||||||
|
|
||||||
_uuidToLocalID.emplace(uuid, newLocalID);
|
_uuidToLocalID.emplace(uuid, newLocalID);
|
||||||
_localIDToUUID.emplace(newLocalID, uuid);
|
_localIDToUUID.emplace(newLocalID, uuid);
|
||||||
|
|
|
@ -1159,7 +1159,8 @@ void DomainServer::handleConnectedNode(SharedNodePointer newNode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const HifiSockAddr &senderSockAddr) {
|
void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const HifiSockAddr &senderSockAddr) {
|
||||||
const int NUM_DOMAIN_LIST_EXTENDED_HEADER_BYTES = NUM_BYTES_RFC4122_UUID + NUM_BYTES_RFC4122_UUID + 2;
|
const int NUM_DOMAIN_LIST_EXTENDED_HEADER_BYTES = NUM_BYTES_RFC4122_UUID + NLPacket::NUM_BYTES_LOCALID +
|
||||||
|
NUM_BYTES_RFC4122_UUID + NLPacket::NUM_BYTES_LOCALID + 2;
|
||||||
|
|
||||||
// setup the extended header for the domain list packets
|
// setup the extended header for the domain list packets
|
||||||
// this data is at the beginning of each of the domain list packets
|
// this data is at the beginning of each of the domain list packets
|
||||||
|
@ -1169,6 +1170,7 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif
|
||||||
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
|
|
||||||
extendedHeaderStream << limitedNodeList->getSessionUUID();
|
extendedHeaderStream << limitedNodeList->getSessionUUID();
|
||||||
|
extendedHeaderStream << limitedNodeList->getSessionLocalID();
|
||||||
extendedHeaderStream << node->getUUID();
|
extendedHeaderStream << node->getUUID();
|
||||||
extendedHeaderStream << node->getLocalID();
|
extendedHeaderStream << node->getLocalID();
|
||||||
extendedHeaderStream << node->getPermissions();
|
extendedHeaderStream << node->getPermissions();
|
||||||
|
|
|
@ -71,7 +71,7 @@ void OctreePacketProcessor::processPacket(QSharedPointer<ReceivedMessage> messag
|
||||||
if (message->getVersion() != versionForPacketType(message->getType())) {
|
if (message->getVersion() != versionForPacketType(message->getType())) {
|
||||||
static QMultiMap<QUuid, PacketType> versionDebugSuppressMap;
|
static QMultiMap<QUuid, PacketType> versionDebugSuppressMap;
|
||||||
|
|
||||||
const QUuid& senderUUID = message->getSourceID();
|
const QUuid& senderUUID = sendingNode->getUUID();
|
||||||
if (!versionDebugSuppressMap.contains(senderUUID, packetType)) {
|
if (!versionDebugSuppressMap.contains(senderUUID, packetType)) {
|
||||||
|
|
||||||
qDebug() << "Was stats packet? " << wasStatsPacket;
|
qDebug() << "Was stats packet? " << wasStatsPacket;
|
||||||
|
|
|
@ -315,10 +315,10 @@ bool LimitedNodeList::packetSourceAndHashMatchAndTrackBandwidth(const udt::Packe
|
||||||
sourceNode = matchingNode.data();
|
sourceNode = matchingNode.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
QUuid sourceID = sourceNode->getUUID();
|
QUuid sourceID = sourceNode ? sourceNode->getUUID() : QUuid();
|
||||||
|
|
||||||
if (!sourceNode &&
|
if (!sourceNode &&
|
||||||
sourceID == getDomainUUID() &&
|
/*sourceID == getDomainUUID() &&*/
|
||||||
packet.getSenderSockAddr() == getDomainSockAddr() &&
|
packet.getSenderSockAddr() == getDomainSockAddr() &&
|
||||||
PacketTypeEnum::getDomainSourcedPackets().contains(headerType)) {
|
PacketTypeEnum::getDomainSourcedPackets().contains(headerType)) {
|
||||||
// This is a packet sourced by the domain server
|
// This is a packet sourced by the domain server
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
||||||
// NLPacket Header Format
|
// NLPacket Header Format
|
||||||
|
|
||||||
using LocalID = qint16;
|
using LocalID = NetworkLocalID;
|
||||||
static const int NUM_BYTES_LOCALID = sizeof(LocalID);
|
static const int NUM_BYTES_LOCALID = sizeof(LocalID);
|
||||||
// this is used by the Octree classes - must be known at compile time
|
// this is used by the Octree classes - must be known at compile time
|
||||||
static const int MAX_PACKET_HEADER_SIZE =
|
static const int MAX_PACKET_HEADER_SIZE =
|
||||||
|
@ -83,7 +83,7 @@ public:
|
||||||
|
|
||||||
LocalID getSourceID() const { return _sourceID; }
|
LocalID getSourceID() const { return _sourceID; }
|
||||||
|
|
||||||
void writeSourceID(qint16 sourceID) const;
|
void writeSourceID(LocalID sourceID) const;
|
||||||
void writeVerificationHashGivenSecret(const QUuid& connectionSecret) const;
|
void writeVerificationHashGivenSecret(const QUuid& connectionSecret) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <QtCore/QTimer>
|
#include <QtCore/QTimer>
|
||||||
#include <QtCore/QUuid>
|
#include <QtCore/QUuid>
|
||||||
|
|
||||||
|
#include "UUID.h"
|
||||||
#include "HifiSockAddr.h"
|
#include "HifiSockAddr.h"
|
||||||
|
|
||||||
const QString ICE_SERVER_HOSTNAME = "localhost";
|
const QString ICE_SERVER_HOSTNAME = "localhost";
|
||||||
|
@ -39,7 +40,7 @@ public:
|
||||||
const QUuid& getUUID() const { return _uuid; }
|
const QUuid& getUUID() const { return _uuid; }
|
||||||
void setUUID(const QUuid& uuid) { _uuid = uuid; }
|
void setUUID(const QUuid& uuid) { _uuid = uuid; }
|
||||||
|
|
||||||
using LocalID = quint16;
|
using LocalID = NetworkLocalID;
|
||||||
LocalID getLocalID() const { return _localID; }
|
LocalID getLocalID() const { return _localID; }
|
||||||
void setLocalID(LocalID localID) { _localID = localID; }
|
void setLocalID(LocalID localID) { _localID = localID; }
|
||||||
|
|
||||||
|
|
|
@ -594,6 +594,9 @@ void NodeList::processDomainServerList(QSharedPointer<ReceivedMessage> message)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Node::LocalID domainLocalID;
|
||||||
|
packetStream >> domainLocalID;
|
||||||
|
|
||||||
// pull our owner (ie. session) UUID from the packet, it's always the first thing
|
// pull our owner (ie. session) UUID from the packet, it's always the first thing
|
||||||
// The short (16 bit) ID comes next.
|
// The short (16 bit) ID comes next.
|
||||||
QUuid newUUID;
|
QUuid newUUID;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <QtCore/QUuid>
|
#include <QtCore/QUuid>
|
||||||
|
|
||||||
const int NUM_BYTES_RFC4122_UUID = 16;
|
const int NUM_BYTES_RFC4122_UUID = 16;
|
||||||
|
using NetworkLocalID = quint16;
|
||||||
|
|
||||||
QString uuidStringWithoutCurlyBraces(const QUuid& uuid);
|
QString uuidStringWithoutCurlyBraces(const QUuid& uuid);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue