erge branch 'atp' of https://github.com/birarda/hifi into protocol

This commit is contained in:
Atlante45 2015-07-15 13:14:21 -07:00
commit 2730201a3e
8 changed files with 26 additions and 19 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

@ -19,6 +19,7 @@
/// Handles assignments of type AvatarMixer - distribution of avatar data to various clients
class AvatarMixer : public ThreadedAssignment {
Q_OBJECT
public:
AvatarMixer(NLPacket& packet);
~AvatarMixer();
@ -26,7 +27,6 @@ public slots:
/// runs the avatar mixer
void run();
void nodeAdded(SharedNodePointer nodeAdded);
void nodeKilled(SharedNodePointer killedNode);
void sendStatsPacket();

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

@ -180,6 +180,7 @@ bool LimitedNodeList::packetSourceAndHashMatch(const NLPacket& packet, SharedNod
if (NON_SOURCED_PACKETS.contains(packet.getType())) {
return true;
} else {
// figure out which node this is from
matchingNode = nodeWithUUID(packet.getSourceID());
@ -199,15 +200,16 @@ bool LimitedNodeList::packetSourceAndHashMatch(const NLPacket& packet, SharedNod
return false;
}
return true;
}
return true;
} else {
static QString repeatedMessage
= LogHandler::getInstance().addRepeatedMessageRegex("Packet of type \\d+ received from unknown node with UUID");
qCDebug(networking) << "Packet of type" << packet.getType() << "received from unknown node with UUID"
<< qPrintable(uuidStringWithoutCurlyBraces(packet.getSourceID()));
qCDebug(networking) << "Packet of type" << packet.getType() << "(" << nameForPacketType(packet.getType()) << ")"
<< "received from unknown node with UUID" << qPrintable(uuidStringWithoutCurlyBraces(packet.getSourceID()));
}
}

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