diff --git a/assignment-client/src/AssignmentClient.cpp b/assignment-client/src/AssignmentClient.cpp index 1029933232..2e044f07ff 100644 --- a/assignment-client/src/AssignmentClient.cpp +++ b/assignment-client/src/AssignmentClient.cpp @@ -73,11 +73,6 @@ AssignmentClient::AssignmentClient(Assignment::Type requestAssignmentType, QStri // put the NodeList on the node thread nodeList->moveToThread(nodeThread); - // make up a uuid for this child so the parent can tell us apart. This id will be changed - // when the domain server hands over an assignment. - QUuid nodeUUID = QUuid::createUuid(); - nodeList->setSessionUUID(nodeUUID); - // set the logging target to the the CHILD_TARGET_NAME LogHandler::getInstance().setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME); @@ -197,7 +192,7 @@ void AssignmentClient::sendStatusPacketToACM() { auto statusPacket = NLPacket::create(PacketType::AssignmentClientStatus, sizeof(assignmentType) + NUM_BYTES_RFC4122_UUID); - statusPacket->write(nodeList->getSessionUUID().toRfc4122()); + statusPacket->write(_childAssignmentUUID.toRfc4122()); statusPacket->writePrimitive(assignmentType); nodeList->sendPacket(std::move(statusPacket), _assignmentClientMonitorSocket); diff --git a/assignment-client/src/AssignmentClient.h b/assignment-client/src/AssignmentClient.h index e74cd50065..1959c915bb 100644 --- a/assignment-client/src/AssignmentClient.h +++ b/assignment-client/src/AssignmentClient.h @@ -51,6 +51,7 @@ private: HifiSockAddr _assignmentServerSocket; QTimer _requestTimer; // timer for requesting and assignment QTimer _statsTimerACM; // timer for sending stats to assignment client monitor + QUuid _childAssignmentUUID = QUuid::createUuid(); protected: HifiSockAddr _assignmentClientMonitorSocket; diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index a7395ffc68..a709986fc7 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -940,7 +940,7 @@ int DomainServer::parseNodeData(QDataStream& packetStream, NodeType_t& nodeType, const HifiSockAddr& senderSockAddr) { packetStream >> nodeType; packetStream >> publicSockAddr >> localSockAddr; - + if (publicSockAddr.getAddress().isNull()) { // this node wants to use us its STUN server // so set the node public address to whatever we perceive the public address to be diff --git a/libraries/networking/src/NLPacket.cpp b/libraries/networking/src/NLPacket.cpp index 0ba81f73e8..4777365d64 100644 --- a/libraries/networking/src/NLPacket.cpp +++ b/libraries/networking/src/NLPacket.cpp @@ -78,29 +78,35 @@ NLPacket::NLPacket(PacketType::Value type, qint64 size) : { Q_ASSERT(size >= 0); - qint64 headerSize = localHeaderSize(type); - _payloadStart += headerSize; - _payloadCapacity -= headerSize; + adjustPayloadStartAndCapacity(); } NLPacket::NLPacket(PacketType::Value type) : Packet(type, -1) { - qint64 headerSize = localHeaderSize(type); - _payloadStart += headerSize; - _payloadCapacity -= headerSize; + adjustPayloadStartAndCapacity(); } NLPacket::NLPacket(const NLPacket& other) : Packet(other) { + } NLPacket::NLPacket(std::unique_ptr data, qint64 size, const HifiSockAddr& senderSockAddr) : Packet(std::move(data), size, senderSockAddr) { + adjustPayloadStartAndCapacity(); + _payloadSize = _payloadCapacity; + readSourceID(); readVerificationHash(); } +void NLPacket::adjustPayloadStartAndCapacity() { + qint64 headerSize = localHeaderSize(_type); + _payloadStart += headerSize; + _payloadCapacity -= headerSize; +} + void NLPacket::readSourceID() { if (!NON_SOURCED_PACKETS.contains(_type)) { auto offset = Packet::totalHeadersSize(); diff --git a/libraries/networking/src/NLPacket.h b/libraries/networking/src/NLPacket.h index e9f397766d..669278ed65 100644 --- a/libraries/networking/src/NLPacket.h +++ b/libraries/networking/src/NLPacket.h @@ -40,6 +40,9 @@ public: QByteArray payloadHashWithConnectionUUID(const QUuid& connectionUUID) const; protected: + + void adjustPayloadStartAndCapacity(); + NLPacket(PacketType::Value type); NLPacket(PacketType::Value type, qint64 size); NLPacket(std::unique_ptr data, qint64 size, const HifiSockAddr& senderSockAddr); diff --git a/libraries/networking/src/udt/Packet.h b/libraries/networking/src/udt/Packet.h index 40d021f2fc..1d499e2b00 100644 --- a/libraries/networking/src/udt/Packet.h +++ b/libraries/networking/src/udt/Packet.h @@ -50,7 +50,7 @@ public: PacketVersion getVersion() const { return _version; } // Returns the size of the packet, including the header - qint64 getDataSize() const { return totalHeadersSize() + getPayloadSize(); } + qint64 getDataSize() const { return totalHeadersSize() + _payloadSize; } // Returns the size of the payload only qint64 getPayloadSize() const { return _payloadSize; }