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:
Simon Walton 2018-03-27 18:18:14 -07:00
parent d3464378b7
commit bed4033554
10 changed files with 23 additions and 23 deletions

View file

@ -117,16 +117,13 @@ void AudioMixer::queueAudioPacket(QSharedPointer<ReceivedMessage> message, Share
void AudioMixer::queueReplicatedAudioPacket(QSharedPointer<ReceivedMessage> message) {
// make sure we have a replicated node for the original sender of the packet
auto nodeList = DependencyManager::get<NodeList>();
QUuid nodeID;
SharedNodePointer sourceNode = nodeList->nodeWithLocalID(message->getSourceID());
if (sourceNode) {
nodeID = sourceNode->getUUID();
}
// Node ID is now part of user data, since replicated audio packets are non-sourced.
QUuid nodeID = QUuid::fromRfc4122(message->readWithoutCopy(NUM_BYTES_RFC4122_UUID));
auto replicatedNode = nodeList->addOrUpdateNode(nodeID, NodeType::Agent,
message->getSenderSockAddr(), message->getSenderSockAddr(),
true, true);
0, true, true);
replicatedNode->setLastHeardMicrostamp(usecTimestampNow());
// 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,
versionForPacketType(rewrittenType),
message->getSenderSockAddr(), message->getSourceID());
message->getSenderSockAddr(), nodeList->getSessionLocalID());
getOrCreateClientData(replicatedNode.data())->queuePacket(replicatedMessage, replicatedNode);
}

View file

@ -74,7 +74,7 @@ SharedNodePointer addOrUpdateReplicatedNode(const QUuid& nodeID, const HifiSockA
auto replicatedNode = DependencyManager::get<NodeList>()->addOrUpdateNode(nodeID, NodeType::Agent,
senderSockAddr,
senderSockAddr,
true, true);
0, true, true);
replicatedNode->setLastHeardMicrostamp(usecTimestampNow());
@ -112,12 +112,8 @@ void AvatarMixer::handleReplicatedPacket(QSharedPointer<ReceivedMessage> message
void AvatarMixer::handleReplicatedBulkAvatarPacket(QSharedPointer<ReceivedMessage> message) {
while (message->getBytesLeftToRead()) {
// first, grab the node ID for this replicated avatar
QUuid nodeID;
auto nodeList = DependencyManager::get<NodeList>();
SharedNodePointer sourceNode = nodeList->nodeWithLocalID(message->getSourceID());
if (sourceNode) {
nodeID = sourceNode->getUUID();
}
// Node ID is now part of user data, since ReplicatedBulkAvatarPacket is non-sourced.
auto nodeID = QUuid::fromRfc4122(message->readWithoutCopy(NUM_BYTES_RFC4122_UUID));
// make sure we have an upstream replicated node that matches
auto replicatedNode = addOrUpdateReplicatedNode(nodeID, message->getSenderSockAddr());

View file

@ -1037,7 +1037,7 @@ Node::LocalID DomainGatekeeper::findOrCreateLocalID(const QUuid& uuid) {
do {
newLocalID = _currentLocalID;
_currentLocalID += _idIncrement;
} while (_localIDToUUID.find(newLocalID) != _localIDToUUID.end());
} while (newLocalID == 0 || _localIDToUUID.find(newLocalID) != _localIDToUUID.end());
_uuidToLocalID.emplace(uuid, newLocalID);
_localIDToUUID.emplace(newLocalID, uuid);

View file

@ -1159,7 +1159,8 @@ void DomainServer::handleConnectedNode(SharedNodePointer newNode) {
}
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
// 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>();
extendedHeaderStream << limitedNodeList->getSessionUUID();
extendedHeaderStream << limitedNodeList->getSessionLocalID();
extendedHeaderStream << node->getUUID();
extendedHeaderStream << node->getLocalID();
extendedHeaderStream << node->getPermissions();

View file

@ -71,7 +71,7 @@ void OctreePacketProcessor::processPacket(QSharedPointer<ReceivedMessage> messag
if (message->getVersion() != versionForPacketType(message->getType())) {
static QMultiMap<QUuid, PacketType> versionDebugSuppressMap;
const QUuid& senderUUID = message->getSourceID();
const QUuid& senderUUID = sendingNode->getUUID();
if (!versionDebugSuppressMap.contains(senderUUID, packetType)) {
qDebug() << "Was stats packet? " << wasStatsPacket;

View file

@ -315,10 +315,10 @@ bool LimitedNodeList::packetSourceAndHashMatchAndTrackBandwidth(const udt::Packe
sourceNode = matchingNode.data();
}
QUuid sourceID = sourceNode->getUUID();
QUuid sourceID = sourceNode ? sourceNode->getUUID() : QUuid();
if (!sourceNode &&
sourceID == getDomainUUID() &&
/*sourceID == getDomainUUID() &&*/
packet.getSenderSockAddr() == getDomainSockAddr() &&
PacketTypeEnum::getDomainSourcedPackets().contains(headerType)) {
// This is a packet sourced by the domain server

View file

@ -43,7 +43,7 @@ public:
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
// NLPacket Header Format
using LocalID = qint16;
using LocalID = NetworkLocalID;
static const int NUM_BYTES_LOCALID = sizeof(LocalID);
// this is used by the Octree classes - must be known at compile time
static const int MAX_PACKET_HEADER_SIZE =
@ -83,7 +83,7 @@ public:
LocalID getSourceID() const { return _sourceID; }
void writeSourceID(qint16 sourceID) const;
void writeSourceID(LocalID sourceID) const;
void writeVerificationHashGivenSecret(const QUuid& connectionSecret) const;
protected:

View file

@ -18,6 +18,7 @@
#include <QtCore/QTimer>
#include <QtCore/QUuid>
#include "UUID.h"
#include "HifiSockAddr.h"
const QString ICE_SERVER_HOSTNAME = "localhost";
@ -39,7 +40,7 @@ public:
const QUuid& getUUID() const { return _uuid; }
void setUUID(const QUuid& uuid) { _uuid = uuid; }
using LocalID = quint16;
using LocalID = NetworkLocalID;
LocalID getLocalID() const { return _localID; }
void setLocalID(LocalID localID) { _localID = localID; }

View file

@ -594,6 +594,9 @@ void NodeList::processDomainServerList(QSharedPointer<ReceivedMessage> message)
return;
}
Node::LocalID domainLocalID;
packetStream >> domainLocalID;
// pull our owner (ie. session) UUID from the packet, it's always the first thing
// The short (16 bit) ID comes next.
QUuid newUUID;

View file

@ -15,6 +15,7 @@
#include <QtCore/QUuid>
const int NUM_BYTES_RFC4122_UUID = 16;
using NetworkLocalID = quint16;
QString uuidStringWithoutCurlyBraces(const QUuid& uuid);