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 // put the NodeList on the node thread
nodeList->moveToThread(nodeThread); 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 // set the logging target to the the CHILD_TARGET_NAME
LogHandler::getInstance().setTargetName(ASSIGNMENT_CLIENT_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); auto statusPacket = NLPacket::create(PacketType::AssignmentClientStatus, sizeof(assignmentType) + NUM_BYTES_RFC4122_UUID);
statusPacket->write(nodeList->getSessionUUID().toRfc4122()); statusPacket->write(_childAssignmentUUID.toRfc4122());
statusPacket->writePrimitive(assignmentType); statusPacket->writePrimitive(assignmentType);
nodeList->sendPacket(std::move(statusPacket), _assignmentClientMonitorSocket); nodeList->sendPacket(std::move(statusPacket), _assignmentClientMonitorSocket);

View file

@ -51,6 +51,7 @@ private:
HifiSockAddr _assignmentServerSocket; HifiSockAddr _assignmentServerSocket;
QTimer _requestTimer; // timer for requesting and assignment QTimer _requestTimer; // timer for requesting and assignment
QTimer _statsTimerACM; // timer for sending stats to assignment client monitor QTimer _statsTimerACM; // timer for sending stats to assignment client monitor
QUuid _childAssignmentUUID = QUuid::createUuid();
protected: protected:
HifiSockAddr _assignmentClientMonitorSocket; HifiSockAddr _assignmentClientMonitorSocket;

View file

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

View file

@ -940,7 +940,7 @@ int DomainServer::parseNodeData(QDataStream& packetStream, NodeType_t& nodeType,
const HifiSockAddr& senderSockAddr) { const HifiSockAddr& senderSockAddr) {
packetStream >> nodeType; packetStream >> nodeType;
packetStream >> publicSockAddr >> localSockAddr; packetStream >> publicSockAddr >> localSockAddr;
if (publicSockAddr.getAddress().isNull()) { if (publicSockAddr.getAddress().isNull()) {
// this node wants to use us its STUN server // this node wants to use us its STUN server
// so set the node public address to whatever we perceive the public address to be // 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())) { if (NON_SOURCED_PACKETS.contains(packet.getType())) {
return true; return true;
} else { } else {
// figure out which node this is from // figure out which node this is from
matchingNode = nodeWithUUID(packet.getSourceID()); matchingNode = nodeWithUUID(packet.getSourceID());
@ -199,15 +200,16 @@ bool LimitedNodeList::packetSourceAndHashMatch(const NLPacket& packet, SharedNod
return false; return false;
} }
return true;
} }
return true;
} else { } else {
static QString repeatedMessage static QString repeatedMessage
= LogHandler::getInstance().addRepeatedMessageRegex("Packet of type \\d+ received from unknown node with UUID"); = 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" qCDebug(networking) << "Packet of type" << packet.getType() << "(" << nameForPacketType(packet.getType()) << ")"
<< qPrintable(uuidStringWithoutCurlyBraces(packet.getSourceID())); << "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); Q_ASSERT(size >= 0);
qint64 headerSize = localHeaderSize(type); adjustPayloadStartAndCapacity();
_payloadStart += headerSize;
_payloadCapacity -= headerSize;
} }
NLPacket::NLPacket(PacketType::Value type) : NLPacket::NLPacket(PacketType::Value type) :
Packet(type, -1) Packet(type, -1)
{ {
qint64 headerSize = localHeaderSize(type); adjustPayloadStartAndCapacity();
_payloadStart += headerSize;
_payloadCapacity -= headerSize;
} }
NLPacket::NLPacket(const NLPacket& other) : Packet(other) { NLPacket::NLPacket(const NLPacket& other) : Packet(other) {
} }
NLPacket::NLPacket(std::unique_ptr<char> data, qint64 size, const HifiSockAddr& senderSockAddr) : NLPacket::NLPacket(std::unique_ptr<char> data, qint64 size, const HifiSockAddr& senderSockAddr) :
Packet(std::move(data), size, senderSockAddr) Packet(std::move(data), size, senderSockAddr)
{ {
adjustPayloadStartAndCapacity();
_payloadSize = _payloadCapacity;
readSourceID(); readSourceID();
readVerificationHash(); readVerificationHash();
} }
void NLPacket::adjustPayloadStartAndCapacity() {
qint64 headerSize = localHeaderSize(_type);
_payloadStart += headerSize;
_payloadCapacity -= headerSize;
}
void NLPacket::readSourceID() { void NLPacket::readSourceID() {
if (!NON_SOURCED_PACKETS.contains(_type)) { if (!NON_SOURCED_PACKETS.contains(_type)) {
auto offset = Packet::totalHeadersSize(); auto offset = Packet::totalHeadersSize();

View file

@ -40,6 +40,9 @@ public:
QByteArray payloadHashWithConnectionUUID(const QUuid& connectionUUID) const; QByteArray payloadHashWithConnectionUUID(const QUuid& connectionUUID) const;
protected: protected:
void adjustPayloadStartAndCapacity();
NLPacket(PacketType::Value type); NLPacket(PacketType::Value type);
NLPacket(PacketType::Value type, qint64 size); NLPacket(PacketType::Value type, qint64 size);
NLPacket(std::unique_ptr<char> data, qint64 size, const HifiSockAddr& senderSockAddr); NLPacket(std::unique_ptr<char> data, qint64 size, const HifiSockAddr& senderSockAddr);

View file

@ -50,7 +50,7 @@ public:
PacketVersion getVersion() const { return _version; } PacketVersion getVersion() const { return _version; }
// Returns the size of the packet, including the header // 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 // Returns the size of the payload only
qint64 getPayloadSize() const { return _payloadSize; } qint64 getPayloadSize() const { return _payloadSize; }