fix child assignment UUID, adjust for NLPacket after unpack

This commit is contained in:
Stephen Birarda 2015-07-15 12:37:30 -07:00
parent c4a97de985
commit e90ace6231
6 changed files with 19 additions and 14 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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

View file

@ -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<char> 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();

View file

@ -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<char> data, qint64 size, const HifiSockAddr& senderSockAddr);

View file

@ -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; }