From 957e6394a9465e20057629502e08737875f9b36f Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 13 Jul 2015 11:57:20 -0700 Subject: [PATCH 01/13] sendPacket function take Node& not a pointer --- assignment-client/src/AssignmentClientMonitor.cpp | 2 +- assignment-client/src/audio/AudioMixer.cpp | 8 ++++---- assignment-client/src/audio/AudioMixerClientData.cpp | 2 +- assignment-client/src/avatars/AvatarMixer.cpp | 4 ++-- assignment-client/src/entities/EntityServer.cpp | 2 +- assignment-client/src/octree/OctreeSendThread.cpp | 10 +++++----- domain-server/src/DomainServer.cpp | 6 +++--- interface/src/Application.cpp | 6 +++--- libraries/audio-client/src/AudioClient.cpp | 4 ++-- libraries/audio-client/src/AudioIOStats.cpp | 2 +- libraries/audio/src/AudioInjector.cpp | 2 +- libraries/networking/src/LimitedNodeList.h | 12 ++++++------ libraries/networking/src/PacketSender.cpp | 2 +- libraries/octree/src/OctreeHeadlessViewer.cpp | 2 +- libraries/script-engine/src/ScriptEngine.cpp | 2 +- 15 files changed, 33 insertions(+), 33 deletions(-) diff --git a/assignment-client/src/AssignmentClientMonitor.cpp b/assignment-client/src/AssignmentClientMonitor.cpp index 6796c122dc..7855956763 100644 --- a/assignment-client/src/AssignmentClientMonitor.cpp +++ b/assignment-client/src/AssignmentClientMonitor.cpp @@ -196,7 +196,7 @@ void AssignmentClientMonitor::checkSpares() { childNode->activateLocalSocket(); auto diePacket = NLPacket::create(PacketType::StopNode, 0); - nodeList->sendPacket(std::move(diePacket), childNode); + nodeList->sendPacket(std::move(diePacket), *childNode); } } } diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index e81f4c66f8..40c1a9d7ab 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -528,7 +528,7 @@ void AudioMixer::sendAudioEnvironmentPacket(SharedNodePointer node) { envPacket->writePrimitive(reverbTime); envPacket->writePrimitive(wetLevel); } - nodeList->sendPacket(std::move(envPacket), node); + nodeList->sendPacket(std::move(envPacket), *node); } } @@ -555,7 +555,7 @@ void AudioMixer::readPendingDatagram(const QByteArray& receivedPacket, const Hif nodeList->eachNode([&](const SharedNodePointer& node){ if (node->getType() == NodeType::Agent && node->getActiveSocket() && node->getLinkedData() && node != sendingNode) { - nodeList->sendPacket(std::move(packet), node); + nodeList->sendPacket(std::move(packet), *node); } }); } @@ -793,7 +793,7 @@ void AudioMixer::run() { if (nodeData->getAvatarAudioStream() && shouldMute(nodeData->getAvatarAudioStream()->getQuietestFrameLoudness())) { auto mutePacket = NLPacket::create(PacketType::NoisyMute, 0); - nodeList->sendPacket(std::move(mutePacket), node); + nodeList->sendPacket(std::move(mutePacket), *node); } if (node->getType() == NodeType::Agent && node->getActiveSocket() @@ -831,7 +831,7 @@ void AudioMixer::run() { sendAudioEnvironmentPacket(node); // send mixed audio packet - nodeList->sendPacket(std::move(mixPacket), node); + nodeList->sendPacket(std::move(mixPacket), *node); nodeData->incrementOutgoingMixedAudioSequenceNumber(); // send an audio stream stats packet if it's time diff --git a/assignment-client/src/audio/AudioMixerClientData.cpp b/assignment-client/src/audio/AudioMixerClientData.cpp index 13cfe4d1a0..0060b45f6e 100644 --- a/assignment-client/src/audio/AudioMixerClientData.cpp +++ b/assignment-client/src/audio/AudioMixerClientData.cpp @@ -190,7 +190,7 @@ void AudioMixerClientData::sendAudioStreamStatsPackets(const SharedNodePointer& numStreamStatsRemaining -= numStreamStatsToPack; // send the current packet - nodeList->sendPacket(std::move(statsPacket), destinationNode); + nodeList->sendPacket(std::move(statsPacket), *destinationNode); } } diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index 0d4e5b5934..487db1b380 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -312,7 +312,7 @@ void AvatarMixer::broadcastAvatarData() { billboardPacket->write(rfcUUID); billboardPacket->write(billboard); - nodeList->sendPacket(std::move(billboardPacket), node); + nodeList->sendPacket(std::move(billboardPacket), *node); ++_sumBillboardPackets; } @@ -330,7 +330,7 @@ void AvatarMixer::broadcastAvatarData() { identityPacket->write(individualData); - nodeList->sendPacket(std::move(identityPacket), node); + nodeList->sendPacket(std::move(identityPacket), *node); ++_sumIdentityPackets; } diff --git a/assignment-client/src/entities/EntityServer.cpp b/assignment-client/src/entities/EntityServer.cpp index 08907380fb..8ec2a82afe 100644 --- a/assignment-client/src/entities/EntityServer.cpp +++ b/assignment-client/src/entities/EntityServer.cpp @@ -101,7 +101,7 @@ int EntityServer::sendSpecialPackets(const SharedNodePointer& node, OctreeQueryN totalBytes += specialPacket->getSizeWithHeader(); packetsSent++; - DependencyManager::get()->sendPacket(std::move(specialPacket), node); + DependencyManager::get()->sendPacket(std::move(specialPacket), *node); } nodeData->setLastDeletedEntitiesSentAt(deletePacketSentAt); diff --git a/assignment-client/src/octree/OctreeSendThread.cpp b/assignment-client/src/octree/OctreeSendThread.cpp index a9619034d9..520b796e47 100644 --- a/assignment-client/src/octree/OctreeSendThread.cpp +++ b/assignment-client/src/octree/OctreeSendThread.cpp @@ -179,12 +179,12 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes // actually send it OctreeServer::didCallWriteDatagram(this); - DependencyManager::get()->sendUnreliablePacket(statsPacket, _node); + DependencyManager::get()->sendUnreliablePacket(statsPacket, *_node); packetSent = true; } else { // not enough room in the packet, send two packets OctreeServer::didCallWriteDatagram(this); - DependencyManager::get()->sendUnreliablePacket(statsPacket, _node); + DependencyManager::get()->sendUnreliablePacket(statsPacket, *_node); // since a stats message is only included on end of scene, don't consider any of these bytes "wasted", since // there was nothing else to send. @@ -215,7 +215,7 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes packetsSent++; OctreeServer::didCallWriteDatagram(this); - DependencyManager::get()->sendUnreliablePacket(nodeData->getPacket(), _node); + DependencyManager::get()->sendUnreliablePacket(nodeData->getPacket(), *_node); packetSent = true; int packetSizeWithHeader = nodeData->getPacket().getSizeWithHeader(); @@ -247,7 +247,7 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes if (nodeData->isPacketWaiting() && !nodeData->isShuttingDown()) { // just send the octree packet OctreeServer::didCallWriteDatagram(this); - DependencyManager::get()->sendUnreliablePacket(nodeData->getPacket(), _node); + DependencyManager::get()->sendUnreliablePacket(nodeData->getPacket(), *_node); packetSent = true; int packetSizeWithHeader = nodeData->getPacket().getSizeWithHeader(); @@ -592,7 +592,7 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus while (nodeData->hasNextNackedPacket() && packetsSentThisInterval < maxPacketsPerInterval) { const NLPacket* packet = nodeData->getNextNackedPacket(); if (packet) { - DependencyManager::get()->sendUnreliablePacket(*packet, _node); + DependencyManager::get()->sendUnreliablePacket(*packet, *_node); truePacketsSent++; packetsSentThisInterval++; diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index a77156a8c9..bb98bb1186 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -1030,7 +1030,7 @@ void DomainServer::broadcastNewNode(const SharedNodePointer& addedNode) { addNodePacket->write(rfcConnectionSecret); // send off this packet to the node - limitedNodeList->sendUnreliablePacket(*addNodePacket, node); + limitedNodeList->sendUnreliablePacket(*addNodePacket, *node); } ); } @@ -1094,7 +1094,7 @@ void DomainServer::readAvailableDatagrams() { assignmentStream << uniqueAssignment; - limitedNodeList->sendUnreliablePacket(*assignmentPacket, senderSockAddr); + limitedNodeList->sendUnreliablePacket(*assignmentPacket, *senderSockAddr); // add the information for that deployed assignment to the hash of pending assigned nodes PendingAssignedNodeData* pendingNodeData = new PendingAssignedNodeData(assignmentToDeploy->getUUID(), @@ -1125,7 +1125,7 @@ void DomainServer::readAvailableDatagrams() { dtlsRequiredPacket->writePrimitive(dtlsPort); } - limitedNodeList->sendUnreliablePacket(*dtlsRequiredPacket, senderSockAddr); + limitedNodeList->sendUnreliablePacket(*dtlsRequiredPacket, *senderSockAddr); } } } diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 04ffe64d8d..09f8e111ba 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1769,7 +1769,7 @@ void Application::sendPingPackets() { return false; } }, [nodeList](const SharedNodePointer& node) { - nodeList->sendPacket(std::move(nodeList->constructPingPacket()), node); + nodeList->sendPacket(std::move(nodeList->constructPingPacket()), *node); }); } @@ -2710,7 +2710,7 @@ int Application::sendNackPackets() { packetsSent += nackPacketList.getNumPackets(); // send the packet list - nodeList->sendPacketList(nackPacketList, node); + nodeList->sendPacketList(nackPacketList, *node); } } }); @@ -2891,7 +2891,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType::Value packetTyp queryPacket->setSizeUsed(packetSize); // make sure we still have an active socket - nodeList->sendUnreliablePacket(*queryPacket, node); + nodeList->sendUnreliablePacket(*queryPacket, *node); } }); } diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index 73a785bb7b..918e5e23db 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -882,7 +882,7 @@ void AudioClient::handleAudioInput() { nodeList->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SendAudioPacket); - nodeList->sendUnreliablePacket(*_audioPacket, audioMixer); + nodeList->sendUnreliablePacket(*_audioPacket, *audioMixer); _outgoingAvatarAudioSequenceNumber++; } @@ -924,7 +924,7 @@ void AudioClient::sendMuteEnvironmentPacket() { if (audioMixer) { // send off this mute packet - nodeList->sendPacket(std::move(mutePacket), audioMixer); + nodeList->sendPacket(std::move(mutePacket), *audioMixer); } } diff --git a/libraries/audio-client/src/AudioIOStats.cpp b/libraries/audio-client/src/AudioIOStats.cpp index 8f7ab2ecaa..d29f976da5 100644 --- a/libraries/audio-client/src/AudioIOStats.cpp +++ b/libraries/audio-client/src/AudioIOStats.cpp @@ -124,5 +124,5 @@ void AudioIOStats::sendDownstreamAudioStatsPacket() { // send packet SharedNodePointer audioMixer = nodeList->soloNodeOfType(NodeType::AudioMixer); - nodeList->sendPacket(std::move(statsPacket), audioMixer); + nodeList->sendPacket(std::move(statsPacket), *audioMixer); } diff --git a/libraries/audio/src/AudioInjector.cpp b/libraries/audio/src/AudioInjector.cpp index c8744ace42..ac11d8f8ca 100644 --- a/libraries/audio/src/AudioInjector.cpp +++ b/libraries/audio/src/AudioInjector.cpp @@ -238,7 +238,7 @@ void AudioInjector::injectToMixer() { SharedNodePointer audioMixer = nodeList->soloNodeOfType(NodeType::AudioMixer); // send off this audio packet - nodeList->sendUnreliablePacket(*audioPacket, audioMixer); + nodeList->sendUnreliablePacket(*audioPacket, *audioMixer); outgoingInjectedAudioSequenceNumber++; _currentSendPosition += bytesToCopy; diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index 5298eec042..715eedc33b 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -123,14 +123,14 @@ public: qint64 readDatagram(QByteArray& incomingPacket, QHostAddress* address, quint16 * port); - qint64 sendUnreliablePacket(const NLPacket& packet, const SharedNodePointer& destinationNode) { assert(false); return 0; } - qint64 sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr) { assert(false); return 0; } + qint64 sendUnreliablePacket(const NLPacket& packet, const Node& destinationNode); + qint64 sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr); - qint64 sendPacket(std::unique_ptr packet, const SharedNodePointer& destinationNode) { assert(false); return 0; } - qint64 sendPacket(std::unique_ptr packet, const HifiSockAddr& sockAddr) { assert(false); return 0; } + qint64 sendPacket(std::unique_ptr packet, const Node& destinationNode); + qint64 sendPacket(std::unique_ptr packet, const HifiSockAddr& sockAddr); - qint64 sendPacketList(NLPacketList& packetList, const SharedNodePointer& destinationNode) { assert(false); return 0; } - qint64 sendPacketList(NLPacketList& packetList, const HifiSockAddr& sockAddr) { assert(false); return 0; } + qint64 sendPacketList(NLPacketList& packetList, const Node& destinationNode); + qint64 sendPacketList(NLPacketList& packetList, const HifiSockAddr& sockAddr); void (*linkedDataCreateCallback)(Node *); diff --git a/libraries/networking/src/PacketSender.cpp b/libraries/networking/src/PacketSender.cpp index de3ee7dc98..3313403033 100644 --- a/libraries/networking/src/PacketSender.cpp +++ b/libraries/networking/src/PacketSender.cpp @@ -272,7 +272,7 @@ bool PacketSender::nonThreadedProcess() { unlock(); // send the packet through the NodeList... - DependencyManager::get()->sendUnreliablePacket(*(packetPair.second), packetPair.first); + DependencyManager::get()->sendUnreliablePacket(*packetPair.second, *packetPair.first); packetsSentThisCall++; _packetsOverCheckInterval++; diff --git a/libraries/octree/src/OctreeHeadlessViewer.cpp b/libraries/octree/src/OctreeHeadlessViewer.cpp index 2a9dd1dd33..168d08082f 100644 --- a/libraries/octree/src/OctreeHeadlessViewer.cpp +++ b/libraries/octree/src/OctreeHeadlessViewer.cpp @@ -219,7 +219,7 @@ void OctreeHeadlessViewer::queryOctree() { _octreeQuery.getBroadcastData(reinterpret_cast(queryPacket->getPayload())); // ask the NodeList to send it - nodeList->sendPacket(std::move(queryPacket), node); + nodeList->sendPacket(std::move(queryPacket), *node); } }); } diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index be959b9f0c..134766fb6b 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -675,7 +675,7 @@ void ScriptEngine::run() { audioPacket->writePrimitive(sequence); // send audio packet - nodeList->sendUnreliablePacket(*audioPacket, node); + nodeList->sendUnreliablePacket(*audioPacket, *node); } }); } From 77bff0c4f278103b6927e1a511f1e962ff9a167a Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 13 Jul 2015 11:57:56 -0700 Subject: [PATCH 02/13] First draft at sendPacket type method impl --- libraries/networking/src/LimitedNodeList.cpp | 52 ++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index dc08f6d200..b668e91590 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -248,6 +248,58 @@ qint64 LimitedNodeList::writeDatagram(const QByteArray& datagram, const HifiSock return bytesWritten; } +qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const Node& destinationNode) { + if (!destinationNode.getActiveSocket()) { + // we don't have a socket to send to, return 0 + return 0; + } + + // use the node's active socket as the destination socket + auto destinationSockAddr = destinationNode.getActiveSocket(); + + return sendUnreliablePacket(packet, *destinationSockAddr); +} + +qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr) { + return writeDatagram(packet.getData(), sockAddr); +} + +qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const Node& destinationNode) { + if (!destinationNode.getActiveSocket()) { + // we don't have a socket to send to, return 0 + return 0; + } + + // use the node's active socket as the destination socket + auto destinationSockAddr = destinationNode.getActiveSocket(); + + return sendPacket(std::move(packet), *destinationSockAddr); +} + +qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const HifiSockAddr& sockAddr) { + return writeDatagram(packet->getData(), sockAddr); +} + +qint64 LimitedNodeList::sendPacketList(NLPacketList& packetList, const Node& destinationNode) { + if (!destinationNode.getActiveSocket()) { + // we don't have a socket to send to, return 0 + return 0; + } + + // use the node's active socket as the destination socket + auto destinationSockAddr = destinationNode.getActiveSocket(); + + return sendPacketList(packetList, *destinationSockAddr); +} + +qint64 LimitedNodeList::sendPacketList(NLPacketList& packetList, const HifiSockAddr& sockAddr) { + // for (auto packet : packetList) { + // + // } + + assert(false); return 0; +} + PacketSequenceNumber LimitedNodeList::getNextSequenceNumberForPacket(const QUuid& nodeUUID, PacketType::Value packetType) { // Thanks to std::map and std::unordered_map this line either default constructs the // PacketType::SequenceMap and the PacketSequenceNumber or returns the existing value. From 7a160db8dd54df9e34e548afa040b1c2e2439139 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 13 Jul 2015 12:58:26 -0700 Subject: [PATCH 03/13] sendPacketList first implementation --- libraries/networking/src/LimitedNodeList.cpp | 33 +++++++++++--------- libraries/networking/src/LimitedNodeList.h | 5 ++- libraries/networking/src/NLPacketList.h | 2 ++ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index b668e91590..8895f09675 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -255,9 +255,7 @@ qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const Node& } // use the node's active socket as the destination socket - auto destinationSockAddr = destinationNode.getActiveSocket(); - - return sendUnreliablePacket(packet, *destinationSockAddr); + return sendUnreliablePacket(packet, *destinationNode.getActiveSocket()); } qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr) { @@ -271,9 +269,7 @@ qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const Node& } // use the node's active socket as the destination socket - auto destinationSockAddr = destinationNode.getActiveSocket(); - - return sendPacket(std::move(packet), *destinationSockAddr); + return sendPacket(std::move(packet), *destinationNode.getActiveSocket()); } qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const HifiSockAddr& sockAddr) { @@ -285,19 +281,26 @@ qint64 LimitedNodeList::sendPacketList(NLPacketList& packetList, const Node& des // we don't have a socket to send to, return 0 return 0; } - - // use the node's active socket as the destination socket - auto destinationSockAddr = destinationNode.getActiveSocket(); - - return sendPacketList(packetList, *destinationSockAddr); + return sendPacketList(packetList, *destinationNode.getActiveSocket()); } qint64 LimitedNodeList::sendPacketList(NLPacketList& packetList, const HifiSockAddr& sockAddr) { - // for (auto packet : packetList) { - // - // } + qint64 bytesSent{ 0 }; + auto& packets = packetList._packets; + while (!packets.empty()) { + bytesSent += sendPacket(std::move(packets.front()), sockAddr); + packets.pop_front(); + } - assert(false); return 0; + return bytesSent; +} + +qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const Node& destinationNode, + const HifiSockAddr& overridenSockAddr) { + // use the node's active socket as the destination socket if there is no overriden socket address + auto& destinationSockAddr = (overridenSockAddr.isNull()) ? *destinationNode.getActiveSocket() + : overridenSockAddr; + return sendPacket(std::move(packet), destinationSockAddr); } PacketSequenceNumber LimitedNodeList::getNextSequenceNumberForPacket(const QUuid& nodeUUID, PacketType::Value packetType) { diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index 715eedc33b..33f9ac9fd3 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -270,9 +270,8 @@ protected: void sendPacketToIceServer(PacketType::Value packetType, const HifiSockAddr& iceServerSockAddr, const QUuid& clientID, const QUuid& peerRequestID = QUuid()); - qint64 sendPacket(std::unique_ptr packet, const SharedNodePointer& destinationNode, - const HifiSockAddr& overridenSockAddr) - { assert(false); return 0; } + qint64 sendPacket(std::unique_ptr packet, const Node& destinationNode, + const HifiSockAddr& overridenSockAddr); QUuid _sessionUUID; diff --git a/libraries/networking/src/NLPacketList.h b/libraries/networking/src/NLPacketList.h index a0a6cdd5eb..3b8150730f 100644 --- a/libraries/networking/src/NLPacketList.h +++ b/libraries/networking/src/NLPacketList.h @@ -41,6 +41,8 @@ protected: virtual qint64 readData(char* data, qint64 maxSize) { return 0; } private: + friend class LimitedNodeList; + NLPacketList(const NLPacketList& other) = delete; NLPacketList& operator=(const NLPacketList& other) = delete; From 4a22f18add3fc8d2cb33c15c124dab1ce453c00a Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 13 Jul 2015 15:25:25 -0700 Subject: [PATCH 04/13] Setup udt namespace/move relevant files --- libraries/networking/src/{ => udt}/Packet.cpp | 0 libraries/networking/src/{ => udt}/Packet.h | 0 .../networking/src/{ => udt}/PacketHeaders.cpp | 0 .../networking/src/{ => udt}/PacketHeaders.h | 0 libraries/networking/src/udt/PacketList.cpp | 12 ++++++++++++ libraries/networking/src/udt/PacketList.h | 15 +++++++++++++++ libraries/networking/src/udt/udt.cpp | 12 ++++++++++++ libraries/networking/src/udt/udt.h | 15 +++++++++++++++ 8 files changed, 54 insertions(+) rename libraries/networking/src/{ => udt}/Packet.cpp (100%) rename libraries/networking/src/{ => udt}/Packet.h (100%) rename libraries/networking/src/{ => udt}/PacketHeaders.cpp (100%) rename libraries/networking/src/{ => udt}/PacketHeaders.h (100%) create mode 100644 libraries/networking/src/udt/PacketList.cpp create mode 100644 libraries/networking/src/udt/PacketList.h create mode 100644 libraries/networking/src/udt/udt.cpp create mode 100644 libraries/networking/src/udt/udt.h diff --git a/libraries/networking/src/Packet.cpp b/libraries/networking/src/udt/Packet.cpp similarity index 100% rename from libraries/networking/src/Packet.cpp rename to libraries/networking/src/udt/Packet.cpp diff --git a/libraries/networking/src/Packet.h b/libraries/networking/src/udt/Packet.h similarity index 100% rename from libraries/networking/src/Packet.h rename to libraries/networking/src/udt/Packet.h diff --git a/libraries/networking/src/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp similarity index 100% rename from libraries/networking/src/PacketHeaders.cpp rename to libraries/networking/src/udt/PacketHeaders.cpp diff --git a/libraries/networking/src/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h similarity index 100% rename from libraries/networking/src/PacketHeaders.h rename to libraries/networking/src/udt/PacketHeaders.h diff --git a/libraries/networking/src/udt/PacketList.cpp b/libraries/networking/src/udt/PacketList.cpp new file mode 100644 index 0000000000..dc9dd36e16 --- /dev/null +++ b/libraries/networking/src/udt/PacketList.cpp @@ -0,0 +1,12 @@ +// +// PacketList.cpp +// +// +// Created by Clement on 7/13/15. +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "PacketList.h" diff --git a/libraries/networking/src/udt/PacketList.h b/libraries/networking/src/udt/PacketList.h new file mode 100644 index 0000000000..4dc8eb2225 --- /dev/null +++ b/libraries/networking/src/udt/PacketList.h @@ -0,0 +1,15 @@ +// +// PacketList.h +// +// +// Created by Clement on 7/13/15. +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_PacketList_h +#define hifi_PacketList_h + +#endif // hifi_PacketList_h \ No newline at end of file diff --git a/libraries/networking/src/udt/udt.cpp b/libraries/networking/src/udt/udt.cpp new file mode 100644 index 0000000000..d580a9f7f8 --- /dev/null +++ b/libraries/networking/src/udt/udt.cpp @@ -0,0 +1,12 @@ +// +// udt.cpp +// +// +// Created by Clement on 7/13/15. +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "udt.h" diff --git a/libraries/networking/src/udt/udt.h b/libraries/networking/src/udt/udt.h new file mode 100644 index 0000000000..74803151d1 --- /dev/null +++ b/libraries/networking/src/udt/udt.h @@ -0,0 +1,15 @@ +// +// udt.h +// +// +// Created by Clement on 7/13/15. +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_udt_h +#define hifi_udt_h + +#endif // hifi_udt_h \ No newline at end of file From c80df94b06451e0112f5a23e6f816f62ea9bdf47 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 13 Jul 2015 15:28:55 -0700 Subject: [PATCH 05/13] Update includes for moved files --- assignment-client/src/Agent.cpp | 2 +- assignment-client/src/AssignmentClient.cpp | 2 +- assignment-client/src/AssignmentClientMonitor.cpp | 2 +- assignment-client/src/AssignmentFactory.cpp | 2 +- assignment-client/src/audio/AudioMixer.cpp | 2 +- assignment-client/src/audio/AudioMixerClientData.cpp | 2 +- assignment-client/src/audio/AvatarAudioStream.cpp | 2 +- assignment-client/src/avatars/AvatarMixer.cpp | 2 +- assignment-client/src/avatars/AvatarMixerClientData.cpp | 2 +- assignment-client/src/avatars/AvatarMixerClientData.h | 2 +- assignment-client/src/entities/EntityNodeData.h | 2 +- assignment-client/src/octree/OctreeInboundPacketProcessor.cpp | 2 +- assignment-client/src/octree/OctreeQueryNode.cpp | 2 +- assignment-client/src/octree/OctreeSendThread.cpp | 2 +- .../src/octree/OctreeServerDatagramProcessor.cpp | 2 +- domain-server/src/DomainServer.cpp | 2 +- domain-server/src/DomainServerNodeData.cpp | 2 +- ice-server/src/IceServer.cpp | 2 +- interface/src/Application.cpp | 2 +- interface/src/Application.h | 4 ++-- interface/src/avatar/Avatar.cpp | 2 +- interface/src/avatar/MyAvatar.cpp | 2 +- libraries/audio-client/src/AudioClient.cpp | 2 +- libraries/audio/src/AudioInjector.cpp | 2 +- libraries/audio/src/AudioRingBuffer.cpp | 2 +- libraries/audio/src/InboundAudioStream.cpp | 2 +- libraries/audio/src/InboundAudioStream.h | 2 +- libraries/audio/src/InjectedAudioStream.cpp | 2 +- libraries/audio/src/MixedAudioStream.h | 2 +- libraries/audio/src/PositionalAudioStream.cpp | 2 +- libraries/avatars/src/AvatarData.cpp | 2 +- libraries/avatars/src/AvatarHashMap.cpp | 2 +- libraries/entities/src/EntityEditPacketSender.cpp | 2 +- libraries/entities/src/EntityItemID.cpp | 2 +- libraries/entities/src/EntityTreeHeadlessViewer.h | 2 +- libraries/environment/src/EnvironmentData.cpp | 2 +- libraries/networking/src/AccountManager.cpp | 2 +- libraries/networking/src/Assignment.cpp | 2 +- libraries/networking/src/DomainHandler.cpp | 2 +- libraries/networking/src/LimitedNodeList.cpp | 2 ++ libraries/networking/src/LimitedNodeList.h | 2 +- libraries/networking/src/NLPacket.h | 2 +- libraries/networking/src/Node.h | 2 +- libraries/networking/src/NodeList.cpp | 2 +- libraries/networking/src/udt/Packet.cpp | 2 +- libraries/octree/src/JurisdictionListener.cpp | 2 +- libraries/octree/src/JurisdictionMap.cpp | 2 +- libraries/octree/src/JurisdictionSender.cpp | 2 +- libraries/octree/src/Octree.cpp | 2 +- libraries/octree/src/OctreeEditPacketSender.cpp | 2 +- libraries/octree/src/OctreeEditPacketSender.h | 2 +- libraries/octree/src/OctreeHeadlessViewer.h | 2 +- libraries/octree/src/OctreePacketData.h | 2 +- libraries/octree/src/OctreeQuery.cpp | 2 +- libraries/octree/src/OctreeRenderer.h | 2 +- libraries/octree/src/OctreeSceneStats.cpp | 2 +- libraries/render-utils/src/Environment.cpp | 2 +- libraries/script-engine/src/ScriptEngine.cpp | 2 +- 58 files changed, 60 insertions(+), 58 deletions(-) diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index 0a4408cbf0..71169893ea 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/assignment-client/src/AssignmentClient.cpp b/assignment-client/src/AssignmentClient.cpp index fd9e4f4f71..76d3716802 100644 --- a/assignment-client/src/AssignmentClient.cpp +++ b/assignment-client/src/AssignmentClient.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/assignment-client/src/AssignmentClientMonitor.cpp b/assignment-client/src/AssignmentClientMonitor.cpp index 7855956763..166491a979 100644 --- a/assignment-client/src/AssignmentClientMonitor.cpp +++ b/assignment-client/src/AssignmentClientMonitor.cpp @@ -18,7 +18,7 @@ #include "AssignmentClientMonitor.h" #include "AssignmentClientApp.h" #include "AssignmentClientChildData.h" -#include "PacketHeaders.h" +#include "udt/PacketHeaders.h" #include "SharedUtil.h" diff --git a/assignment-client/src/AssignmentFactory.cpp b/assignment-client/src/AssignmentFactory.cpp index 4dafd64a92..c2f6f5c22c 100644 --- a/assignment-client/src/AssignmentFactory.cpp +++ b/assignment-client/src/AssignmentFactory.cpp @@ -9,7 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include +#include #include "Agent.h" #include "AssignmentFactory.h" diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index 40c1a9d7ab..edb9db92fa 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/assignment-client/src/audio/AudioMixerClientData.cpp b/assignment-client/src/audio/AudioMixerClientData.cpp index 0060b45f6e..e933982bb0 100644 --- a/assignment-client/src/audio/AudioMixerClientData.cpp +++ b/assignment-client/src/audio/AudioMixerClientData.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include "InjectedAudioStream.h" diff --git a/assignment-client/src/audio/AvatarAudioStream.cpp b/assignment-client/src/audio/AvatarAudioStream.cpp index 68f8f718de..fc14bcede6 100644 --- a/assignment-client/src/audio/AvatarAudioStream.cpp +++ b/assignment-client/src/audio/AvatarAudioStream.cpp @@ -9,7 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include +#include #include "AvatarAudioStream.h" diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index 487db1b380..4e5f7f91d4 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include diff --git a/assignment-client/src/avatars/AvatarMixerClientData.cpp b/assignment-client/src/avatars/AvatarMixerClientData.cpp index 197e9baf5e..44552f5ccd 100644 --- a/assignment-client/src/avatars/AvatarMixerClientData.cpp +++ b/assignment-client/src/avatars/AvatarMixerClientData.cpp @@ -9,7 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include +#include #include "AvatarMixerClientData.h" diff --git a/assignment-client/src/avatars/AvatarMixerClientData.h b/assignment-client/src/avatars/AvatarMixerClientData.h index 3e10b8473a..e45c0c9e54 100644 --- a/assignment-client/src/avatars/AvatarMixerClientData.h +++ b/assignment-client/src/avatars/AvatarMixerClientData.h @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include diff --git a/assignment-client/src/entities/EntityNodeData.h b/assignment-client/src/entities/EntityNodeData.h index 054ceb07d3..d779a0b58d 100644 --- a/assignment-client/src/entities/EntityNodeData.h +++ b/assignment-client/src/entities/EntityNodeData.h @@ -12,7 +12,7 @@ #ifndef hifi_EntityNodeData_h #define hifi_EntityNodeData_h -#include +#include #include "../octree/OctreeQueryNode.h" diff --git a/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp b/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp index 613eec18df..ebc18162d9 100644 --- a/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp +++ b/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include "OctreeServer.h" diff --git a/assignment-client/src/octree/OctreeQueryNode.cpp b/assignment-client/src/octree/OctreeQueryNode.cpp index 7df9604817..2f1a554b8c 100644 --- a/assignment-client/src/octree/OctreeQueryNode.cpp +++ b/assignment-client/src/octree/OctreeQueryNode.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include diff --git a/assignment-client/src/octree/OctreeSendThread.cpp b/assignment-client/src/octree/OctreeSendThread.cpp index 520b796e47..6a5d76d4b9 100644 --- a/assignment-client/src/octree/OctreeSendThread.cpp +++ b/assignment-client/src/octree/OctreeSendThread.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include "OctreeSendThread.h" diff --git a/assignment-client/src/octree/OctreeServerDatagramProcessor.cpp b/assignment-client/src/octree/OctreeServerDatagramProcessor.cpp index 94249e7517..084fd13ab5 100644 --- a/assignment-client/src/octree/OctreeServerDatagramProcessor.cpp +++ b/assignment-client/src/octree/OctreeServerDatagramProcessor.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include "OctreeServerDatagramProcessor.h" diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index bb98bb1186..9cdac34c30 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/domain-server/src/DomainServerNodeData.cpp b/domain-server/src/DomainServerNodeData.cpp index 0d7efa064c..795b2f4aef 100644 --- a/domain-server/src/DomainServerNodeData.cpp +++ b/domain-server/src/DomainServerNodeData.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include #include "DomainServerNodeData.h" diff --git a/ice-server/src/IceServer.cpp b/ice-server/src/IceServer.cpp index 24199b8bb8..1e9e3e8ec4 100644 --- a/ice-server/src/IceServer.cpp +++ b/ice-server/src/IceServer.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include "IceServer.h" diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 09f8e111ba..ee90d222c6 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -81,7 +81,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/interface/src/Application.h b/interface/src/Application.h index 0131fdb19a..26b1e0caee 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include @@ -48,7 +48,6 @@ #include "FileLogger.h" #include "GLCanvas.h" #include "Menu.h" -#include "PacketHeaders.h" #include "Physics.h" #include "Stars.h" #include "avatar/Avatar.h" @@ -56,6 +55,7 @@ #include "devices/SixenseManager.h" #include "scripting/ControllerScriptingInterface.h" #include "scripting/WebWindowClass.h" +#include "udt/PacketHeaders.h" #include "ui/BandwidthDialog.h" #include "ui/HMDToolsDialog.h" #include "ui/ModelsBrowser.h" diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 3d4c158a0b..ca983287ad 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 1384f6e9ca..dc83d8e07f 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index 918e5e23db..23cfcd3000 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -50,7 +50,7 @@ extern "C" { #include #include -#include +#include #include #include #include diff --git a/libraries/audio/src/AudioInjector.cpp b/libraries/audio/src/AudioInjector.cpp index ac11d8f8ca..4866bcfad6 100644 --- a/libraries/audio/src/AudioInjector.cpp +++ b/libraries/audio/src/AudioInjector.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include #include diff --git a/libraries/audio/src/AudioRingBuffer.cpp b/libraries/audio/src/AudioRingBuffer.cpp index 8330414c4a..fc46d5fd66 100644 --- a/libraries/audio/src/AudioRingBuffer.cpp +++ b/libraries/audio/src/AudioRingBuffer.cpp @@ -16,7 +16,7 @@ #include -#include +#include #include "AudioLogging.h" diff --git a/libraries/audio/src/InboundAudioStream.cpp b/libraries/audio/src/InboundAudioStream.cpp index 928662d2e8..9df083159f 100644 --- a/libraries/audio/src/InboundAudioStream.cpp +++ b/libraries/audio/src/InboundAudioStream.cpp @@ -12,7 +12,7 @@ #include #include "InboundAudioStream.h" -#include "PacketHeaders.h" +#include "udt/PacketHeaders.h" const int STARVE_HISTORY_CAPACITY = 50; diff --git a/libraries/audio/src/InboundAudioStream.h b/libraries/audio/src/InboundAudioStream.h index cb8494f23e..65a0e5ddaa 100644 --- a/libraries/audio/src/InboundAudioStream.h +++ b/libraries/audio/src/InboundAudioStream.h @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include "AudioRingBuffer.h" diff --git a/libraries/audio/src/InjectedAudioStream.cpp b/libraries/audio/src/InjectedAudioStream.cpp index b7e9a40942..e7633c49e7 100644 --- a/libraries/audio/src/InjectedAudioStream.cpp +++ b/libraries/audio/src/InjectedAudioStream.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include "InjectedAudioStream.h" diff --git a/libraries/audio/src/MixedAudioStream.h b/libraries/audio/src/MixedAudioStream.h index edb26c486f..e6c0339b2a 100644 --- a/libraries/audio/src/MixedAudioStream.h +++ b/libraries/audio/src/MixedAudioStream.h @@ -13,7 +13,7 @@ #define hifi_MixedAudioStream_h #include "InboundAudioStream.h" -#include "PacketHeaders.h" +#include "udt/PacketHeaders.h" class MixedAudioStream : public InboundAudioStream { public: diff --git a/libraries/audio/src/PositionalAudioStream.cpp b/libraries/audio/src/PositionalAudioStream.cpp index 7ca18db540..a916ccf2e3 100644 --- a/libraries/audio/src/PositionalAudioStream.cpp +++ b/libraries/audio/src/PositionalAudioStream.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include PositionalAudioStream::PositionalAudioStream(PositionalAudioStream::Type type, bool isStereo, const InboundAudioStream::Settings& settings) : diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 5ea3b4c669..06e05a9390 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include diff --git a/libraries/avatars/src/AvatarHashMap.cpp b/libraries/avatars/src/AvatarHashMap.cpp index 60eb5c4499..f2742b63ea 100644 --- a/libraries/avatars/src/AvatarHashMap.cpp +++ b/libraries/avatars/src/AvatarHashMap.cpp @@ -10,7 +10,7 @@ // #include -#include +#include #include #include "AvatarLogging.h" diff --git a/libraries/entities/src/EntityEditPacketSender.cpp b/libraries/entities/src/EntityEditPacketSender.cpp index 0faba6541c..616e8f75d5 100644 --- a/libraries/entities/src/EntityEditPacketSender.cpp +++ b/libraries/entities/src/EntityEditPacketSender.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include "EntityEditPacketSender.h" #include "EntitiesLogging.h" #include "EntityItem.h" diff --git a/libraries/entities/src/EntityItemID.cpp b/libraries/entities/src/EntityItemID.cpp index d882559ee3..ab2c39324f 100644 --- a/libraries/entities/src/EntityItemID.cpp +++ b/libraries/entities/src/EntityItemID.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include "RegisteredMetaTypes.h" #include "EntityItemID.h" diff --git a/libraries/entities/src/EntityTreeHeadlessViewer.h b/libraries/entities/src/EntityTreeHeadlessViewer.h index fedbc74430..23c32546cb 100644 --- a/libraries/entities/src/EntityTreeHeadlessViewer.h +++ b/libraries/entities/src/EntityTreeHeadlessViewer.h @@ -12,7 +12,7 @@ #ifndef hifi_EntityTreeHeadlessViewer_h #define hifi_EntityTreeHeadlessViewer_h -#include +#include #include #include #include diff --git a/libraries/environment/src/EnvironmentData.cpp b/libraries/environment/src/EnvironmentData.cpp index f703b667bc..2c6fe5b491 100644 --- a/libraries/environment/src/EnvironmentData.cpp +++ b/libraries/environment/src/EnvironmentData.cpp @@ -12,7 +12,7 @@ #include #include "EnvironmentData.h" -#include "PacketHeaders.h" +#include "udt/PacketHeaders.h" // initial values from Sean O'Neil's GPU Gems entry (http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter16.html), // GameEngine.cpp diff --git a/libraries/networking/src/AccountManager.cpp b/libraries/networking/src/AccountManager.cpp index 2830a13ca7..4ded2216d0 100644 --- a/libraries/networking/src/AccountManager.cpp +++ b/libraries/networking/src/AccountManager.cpp @@ -24,7 +24,7 @@ #include #include "NodeList.h" -#include "PacketHeaders.h" +#include "udt/PacketHeaders.h" #include "RSAKeypairGenerator.h" #include "SharedUtil.h" diff --git a/libraries/networking/src/Assignment.cpp b/libraries/networking/src/Assignment.cpp index 3da1fb9a41..16d7b6a051 100644 --- a/libraries/networking/src/Assignment.cpp +++ b/libraries/networking/src/Assignment.cpp @@ -9,7 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "PacketHeaders.h" +#include "udt/PacketHeaders.h" #include "SharedUtil.h" #include "UUID.h" diff --git a/libraries/networking/src/DomainHandler.cpp b/libraries/networking/src/DomainHandler.cpp index 38d1ade2ad..568c4b1e9b 100644 --- a/libraries/networking/src/DomainHandler.cpp +++ b/libraries/networking/src/DomainHandler.cpp @@ -16,7 +16,7 @@ #include "Assignment.h" #include "HifiSockAddr.h" #include "NodeList.h" -#include "PacketHeaders.h" +#include "udt/PacketHeaders.h" #include "SharedUtil.h" #include "UserActivityLogger.h" #include "NetworkLogging.h" diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 8895f09675..d54fbd093b 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -33,6 +33,8 @@ #include "UUID.h" #include "NetworkLogging.h" +#include "udt/udt.h" + const char SOLO_NODE_TYPES[2] = { NodeType::AvatarMixer, NodeType::AudioMixer diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index 33f9ac9fd3..3d9f85aa08 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -38,7 +38,7 @@ #include "DomainHandler.h" #include "Node.h" #include "NLPacket.h" -#include "PacketHeaders.h" +#include "udt/PacketHeaders.h" #include "NLPacketList.h" #include "UUIDHasher.h" diff --git a/libraries/networking/src/NLPacket.h b/libraries/networking/src/NLPacket.h index e70df1dad7..6c38f1eb2e 100644 --- a/libraries/networking/src/NLPacket.h +++ b/libraries/networking/src/NLPacket.h @@ -12,7 +12,7 @@ #ifndef hifi_NLPacket_h #define hifi_NLPacket_h -#include "Packet.h" +#include "udt/Packet.h" class NLPacket : public Packet { Q_OBJECT diff --git a/libraries/networking/src/Node.h b/libraries/networking/src/Node.h index 83bdf0ebd3..3bd79d01f0 100644 --- a/libraries/networking/src/Node.h +++ b/libraries/networking/src/Node.h @@ -24,7 +24,7 @@ #include "NetworkPeer.h" #include "NodeData.h" #include "NodeType.h" -#include "PacketHeaders.h" +#include "udt/PacketHeaders.h" #include "SimpleMovingAverage.h" #include "MovingPercentile.h" diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index dd1d4bdc5f..3e6418c7f6 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -25,7 +25,7 @@ #include "HifiSockAddr.h" #include "JSONBreakableMarshal.h" #include "NodeList.h" -#include "PacketHeaders.h" +#include "udt/PacketHeaders.h" #include "SharedUtil.h" #include "UUID.h" #include "NetworkLogging.h" diff --git a/libraries/networking/src/udt/Packet.cpp b/libraries/networking/src/udt/Packet.cpp index ca1c66f4ca..f7a52b068a 100644 --- a/libraries/networking/src/udt/Packet.cpp +++ b/libraries/networking/src/udt/Packet.cpp @@ -11,7 +11,7 @@ #include "Packet.h" -#include "LimitedNodeList.h" +#include "../LimitedNodeList.h" qint64 Packet::localHeaderSize(PacketType::Value type) { qint64 size = numBytesForArithmeticCodedPacketType(type) + sizeof(PacketVersion) + diff --git a/libraries/octree/src/JurisdictionListener.cpp b/libraries/octree/src/JurisdictionListener.cpp index d725ce3555..735fcb0725 100644 --- a/libraries/octree/src/JurisdictionListener.cpp +++ b/libraries/octree/src/JurisdictionListener.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include #include "JurisdictionListener.h" JurisdictionListener::JurisdictionListener(NodeType_t type) : diff --git a/libraries/octree/src/JurisdictionMap.cpp b/libraries/octree/src/JurisdictionMap.cpp index d6e4ad8003..5fc735eb68 100644 --- a/libraries/octree/src/JurisdictionMap.cpp +++ b/libraries/octree/src/JurisdictionMap.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include "OctreeLogging.h" diff --git a/libraries/octree/src/JurisdictionSender.cpp b/libraries/octree/src/JurisdictionSender.cpp index 1ade2412b8..69ae76840e 100644 --- a/libraries/octree/src/JurisdictionSender.cpp +++ b/libraries/octree/src/JurisdictionSender.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include #include "JurisdictionSender.h" diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index ca6cfcecba..810bfa6097 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/libraries/octree/src/OctreeEditPacketSender.cpp b/libraries/octree/src/OctreeEditPacketSender.cpp index 41b8b7bca6..6bbfdc5024 100644 --- a/libraries/octree/src/OctreeEditPacketSender.cpp +++ b/libraries/octree/src/OctreeEditPacketSender.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include #include "OctreeLogging.h" #include "OctreeEditPacketSender.h" diff --git a/libraries/octree/src/OctreeEditPacketSender.h b/libraries/octree/src/OctreeEditPacketSender.h index a1ba2f0675..34fed80e98 100644 --- a/libraries/octree/src/OctreeEditPacketSender.h +++ b/libraries/octree/src/OctreeEditPacketSender.h @@ -13,7 +13,7 @@ #define hifi_OctreeEditPacketSender_h #include -#include +#include #include "JurisdictionMap.h" #include "SentPacketHistory.h" diff --git a/libraries/octree/src/OctreeHeadlessViewer.h b/libraries/octree/src/OctreeHeadlessViewer.h index 70ee43be35..692b7e4848 100644 --- a/libraries/octree/src/OctreeHeadlessViewer.h +++ b/libraries/octree/src/OctreeHeadlessViewer.h @@ -12,7 +12,7 @@ #ifndef hifi_OctreeHeadlessViewer_h #define hifi_OctreeHeadlessViewer_h -#include +#include #include #include "JurisdictionListener.h" diff --git a/libraries/octree/src/OctreePacketData.h b/libraries/octree/src/OctreePacketData.h index 5ce44a0457..439a07087c 100644 --- a/libraries/octree/src/OctreePacketData.h +++ b/libraries/octree/src/OctreePacketData.h @@ -27,7 +27,7 @@ #include #include // for MAX_PACKET_SIZE -#include // for MAX_PACKET_HEADER_BYTES +#include // for MAX_PACKET_HEADER_BYTES #include #include #include diff --git a/libraries/octree/src/OctreeQuery.cpp b/libraries/octree/src/OctreeQuery.cpp index 08197a587e..3bfa8c0fff 100644 --- a/libraries/octree/src/OctreeQuery.cpp +++ b/libraries/octree/src/OctreeQuery.cpp @@ -10,7 +10,7 @@ // #include -#include +#include #include "OctreeConstants.h" #include "OctreeQuery.h" diff --git a/libraries/octree/src/OctreeRenderer.h b/libraries/octree/src/OctreeRenderer.h index f6c92f81c9..e470b088d1 100644 --- a/libraries/octree/src/OctreeRenderer.h +++ b/libraries/octree/src/OctreeRenderer.h @@ -17,7 +17,7 @@ #include -#include +#include #include #include diff --git a/libraries/octree/src/OctreeSceneStats.cpp b/libraries/octree/src/OctreeSceneStats.cpp index c4367b43d8..3633f05e2d 100644 --- a/libraries/octree/src/OctreeSceneStats.cpp +++ b/libraries/octree/src/OctreeSceneStats.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include "OctreePacketData.h" #include "OctreeElement.h" diff --git a/libraries/render-utils/src/Environment.cpp b/libraries/render-utils/src/Environment.cpp index 411beca0ae..763bbc460a 100644 --- a/libraries/render-utils/src/Environment.cpp +++ b/libraries/render-utils/src/Environment.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index 134766fb6b..1fc54fa35a 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include "AnimationObject.h" From 44c5d4a2bfd6abd395e842a8a210328da7e671de Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 13 Jul 2015 15:29:41 -0700 Subject: [PATCH 06/13] Couple fixes SharedNodePointer > Node& --- assignment-client/src/audio/AudioMixerClientData.cpp | 3 --- libraries/networking/src/NodeList.cpp | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/assignment-client/src/audio/AudioMixerClientData.cpp b/assignment-client/src/audio/AudioMixerClientData.cpp index e933982bb0..1e0bc6d9b2 100644 --- a/assignment-client/src/audio/AudioMixerClientData.cpp +++ b/assignment-client/src/audio/AudioMixerClientData.cpp @@ -159,10 +159,7 @@ void AudioMixerClientData::sendAudioStreamStatsPackets(const SharedNodePointer& int numStreamStatsRemaining = _audioStreams.size(); QHash::ConstIterator audioStreamsIterator = _audioStreams.constBegin(); - NLPacketList statsPacketList(PacketType::AudioStreamStats); - while (numStreamStatsRemaining > 0) { - auto statsPacket = NLPacket::create(PacketType::AudioStreamStats); // pack the append flag in this packet diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 3e6418c7f6..20206c88ce 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -184,7 +184,7 @@ void NodeList::processNodeData(const HifiSockAddr& senderSockAddr, const QByteAr if (matchingNode) { matchingNode->setLastHeardMicrostamp(usecTimestampNow()); auto replyPacket = constructPingReplyPacket(packet); - sendPacket(std::move(replyPacket), matchingNode, senderSockAddr); + sendPacket(std::move(replyPacket), *matchingNode, senderSockAddr); // If we don't have a symmetric socket for this node and this socket doesn't match // what we have for public and local then set it as the symmetric. @@ -611,14 +611,14 @@ void NodeList::pingPunchForInactiveNode(const SharedNodePointer& node) { // send the ping packet to the local and public sockets for this node auto localPingPacket = constructPingPacket(PingType::Local); - sendPacket(std::move(localPingPacket), node, node->getLocalSocket()); + sendPacket(std::move(localPingPacket), *node, node->getLocalSocket()); auto publicPingPacket = constructPingPacket(PingType::Public); - sendPacket(std::move(publicPingPacket), node, node->getPublicSocket()); + sendPacket(std::move(publicPingPacket), *node, node->getPublicSocket()); if (!node->getSymmetricSocket().isNull()) { auto symmetricPingPacket = constructPingPacket(PingType::Symmetric); - sendPacket(std::move(symmetricPingPacket), node, node->getSymmetricSocket()); + sendPacket(std::move(symmetricPingPacket), *node, node->getSymmetricSocket()); } node->incrementConnectionAttempts(); From eb5699907770cc202b3f3e609f379f8c458a856d Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 13 Jul 2015 15:30:41 -0700 Subject: [PATCH 07/13] Make PacketList class NLPacketList inherits from --- libraries/networking/src/NLPacketList.cpp | 96 +---------------- libraries/networking/src/NLPacketList.h | 54 +--------- libraries/networking/src/udt/PacketList.cpp | 111 ++++++++++++++++++++ libraries/networking/src/udt/PacketList.h | 58 ++++++++++ 4 files changed, 178 insertions(+), 141 deletions(-) diff --git a/libraries/networking/src/NLPacketList.cpp b/libraries/networking/src/NLPacketList.cpp index 8cadc1b9f5..85b413eda9 100644 --- a/libraries/networking/src/NLPacketList.cpp +++ b/libraries/networking/src/NLPacketList.cpp @@ -11,100 +11,12 @@ #include "NLPacketList.h" -#include - -NLPacketList::NLPacketList(PacketType::Value packetType) : - _packetType(packetType) -{ +#include "NLPacket.h" +NLPacketList::NLPacketList(PacketType::Value packetType) : PacketList(packetType) { } -std::unique_ptr NLPacketList::createPacketWithExtendedHeader() { - // use the static create method to create a new packet - auto packet = NLPacket::create(_packetType); - - // add the extended header to the front of the packet - if (packet->write(_extendedHeader) == -1) { - qDebug() << "Could not write extendedHeader in PacketList::createPacketWithExtendedHeader" - << "- make sure that _extendedHeader is not larger than the payload capacity."; - } - - return packet; -} - -qint64 NLPacketList::writeData(const char* data, qint64 maxSize) { - if (!_currentPacket) { - // we don't have a current packet, time to set one up - _currentPacket = createPacketWithExtendedHeader(); - } - - // check if this block of data can fit into the currentPacket - if (maxSize <= _currentPacket->bytesAvailable()) { - // it fits, just write it to the current packet - _currentPacket->write(data, maxSize); - - // return the number of bytes written - return maxSize; - } else { - // it does not fit - this may need to be in the next packet - - if (!_isOrdered) { - auto newPacket = createPacketWithExtendedHeader(); - - if (_segmentStartIndex >= 0) { - // We in the process of writing a segment for an unordered PacketList. - // We need to try and pull the first part of the segment out to our new packet - - // check now to see if this is an unsupported write - int numBytesToEnd = _currentPacket->bytesAvailable(); - - if ((newPacket->size() - numBytesToEnd) < maxSize) { - // this is an unsupported case - the segment is bigger than the size of an individual packet - // but the PacketList is not going to be sent ordered - qDebug() << "Error in PacketList::writeData - attempted to write a segment to an unordered packet that is" - << "larger than the payload size."; - Q_ASSERT(false); - } - - // copy from currentPacket where the segment started to the beginning of the newPacket - newPacket->write(_currentPacket->getPayload() + _segmentStartIndex, numBytesToEnd); - - // the current segment now starts at the beginning of the new packet - _segmentStartIndex = 0; - - // shrink the current payload to the actual size of the packet - _currentPacket->setSizeUsed(_segmentStartIndex); - } - - // move the current packet to our list of packets - _packets.push_back(std::move(_currentPacket)); - - // write the data to the newPacket - newPacket->write(data, maxSize); - - // swap our current packet with the new packet - _currentPacket.swap(newPacket); - - // return the number of bytes written to the new packet - return maxSize; - } else { - // we're an ordered PacketList - let's fit what we can into the current packet and then put the leftover - // into a new packet - - int numBytesToEnd = _currentPacket->bytesAvailable(); - _currentPacket->write(data, numBytesToEnd); - - // move the current packet to our list of packets - _packets.push_back(std::move(_currentPacket)); - - // recursively call our writeData method for the remaining data to write to a new packet - return numBytesToEnd + writeData(data + numBytesToEnd, maxSize - numBytesToEnd); - } - } -} - -void NLPacketList::closeCurrentPacket() { - // move the current packet to our list of packets - _packets.push_back(std::move(_currentPacket)); +std::unique_ptr NLPacketList::createPacket() { + return std::move(NLPacket::create(getType())); } diff --git a/libraries/networking/src/NLPacketList.h b/libraries/networking/src/NLPacketList.h index 3b8150730f..a1a483781d 100644 --- a/libraries/networking/src/NLPacketList.h +++ b/libraries/networking/src/NLPacketList.h @@ -12,61 +12,17 @@ #ifndef hifi_NLPacketList_h #define hifi_NLPacketList_h -#include +#include "udt/PacketList.h" -#include "PacketHeaders.h" - -#include "NLPacket.h" - -class NLPacketList : public QIODevice { - Q_OBJECT +class NLPacketList : public PacketList { public: NLPacketList(PacketType::Value packetType); - - virtual bool isSequential() const { return true; } - - void startSegment() { _segmentStartIndex = _currentPacket->pos(); } - void endSegment() { _segmentStartIndex = -1; } - - int getNumPackets() const { return _packets.size() + (_currentPacket ? 1 : 0); } - - void closeCurrentPacket(); - - void setExtendedHeader(const QByteArray& extendedHeader) { _extendedHeader = extendedHeader; } - - template qint64 readPrimitive(T* data); - template qint64 writePrimitive(const T& data); -protected: - virtual qint64 writeData(const char* data, qint64 maxSize); - virtual qint64 readData(char* data, qint64 maxSize) { return 0; } - -private: - friend class LimitedNodeList; +private: NLPacketList(const NLPacketList& other) = delete; NLPacketList& operator=(const NLPacketList& other) = delete; - - std::unique_ptr createPacketWithExtendedHeader(); - - PacketType::Value _packetType; - bool _isOrdered = false; - - std::unique_ptr _currentPacket; - std::list> _packets; - - int _segmentStartIndex = -1; - - QByteArray _extendedHeader; + + virtual std::unique_ptr createPacket(); }; -template qint64 NLPacketList::readPrimitive(T* data) { - return QIODevice::read(reinterpret_cast(data), sizeof(T)); -} - -template qint64 NLPacketList::writePrimitive(const T& data) { - static_assert(!std::is_pointer::value, "T must not be a pointer"); - return QIODevice::write(reinterpret_cast(&data), sizeof(T)); -} - - #endif // hifi_PacketList_h diff --git a/libraries/networking/src/udt/PacketList.cpp b/libraries/networking/src/udt/PacketList.cpp index dc9dd36e16..43e0b2a4ea 100644 --- a/libraries/networking/src/udt/PacketList.cpp +++ b/libraries/networking/src/udt/PacketList.cpp @@ -10,3 +10,114 @@ // #include "PacketList.h" + +#include + +#include "Packet.h" + +PacketList::PacketList(PacketType::Value packetType) : _packetType(packetType) { +} + +void PacketList::startSegment() { + _segmentStartIndex = _currentPacket->pos(); +} + +void PacketList::endSegment() { + _segmentStartIndex = -1; +} + +std::unique_ptr PacketList::createPacket() { + // use the static create method to create a new packet + return std::move(Packet::create(getType())); +} + +std::unique_ptr PacketList::createPacketWithExtendedHeader() { + // use the static create method to create a new packet + auto packet = createPacket(); + + if (!_extendedHeader.isEmpty()) { + // add the extended header to the front of the packet + if (packet->write(_extendedHeader) == -1) { + qDebug() << "Could not write extendedHeader in PacketList::createPacketWithExtendedHeader" + << "- make sure that _extendedHeader is not larger than the payload capacity."; + } + } + + return std::move(packet); +} + +qint64 PacketList::writeData(const char* data, qint64 maxSize) { + if (!_currentPacket) { + // we don't have a current packet, time to set one up + _currentPacket = createPacketWithExtendedHeader(); + } + + // check if this block of data can fit into the currentPacket + if (maxSize <= _currentPacket->bytesAvailable()) { + // it fits, just write it to the current packet + _currentPacket->write(data, maxSize); + + // return the number of bytes written + return maxSize; + } else { + // it does not fit - this may need to be in the next packet + + if (!_isOrdered) { + auto newPacket = createPacketWithExtendedHeader(); + + if (_segmentStartIndex >= 0) { + // We in the process of writing a segment for an unordered PacketList. + // We need to try and pull the first part of the segment out to our new packet + + // check now to see if this is an unsupported write + int numBytesToEnd = _currentPacket->bytesAvailable(); + + if ((newPacket->size() - numBytesToEnd) < maxSize) { + // this is an unsupported case - the segment is bigger than the size of an individual packet + // but the PacketList is not going to be sent ordered + qDebug() << "Error in PacketList::writeData - attempted to write a segment to an unordered packet that is" + << "larger than the payload size."; + Q_ASSERT(false); + } + + // copy from currentPacket where the segment started to the beginning of the newPacket + newPacket->write(_currentPacket->getPayload() + _segmentStartIndex, numBytesToEnd); + + // the current segment now starts at the beginning of the new packet + _segmentStartIndex = 0; + + // shrink the current payload to the actual size of the packet + _currentPacket->setSizeUsed(_segmentStartIndex); + } + + // move the current packet to our list of packets + _packets.push_back(std::move(_currentPacket)); + + // write the data to the newPacket + newPacket->write(data, maxSize); + + // swap our current packet with the new packet + _currentPacket.swap(newPacket); + + // return the number of bytes written to the new packet + return maxSize; + } else { + // we're an ordered PacketList - let's fit what we can into the current packet and then put the leftover + // into a new packet + + int numBytesToEnd = _currentPacket->bytesAvailable(); + _currentPacket->write(data, numBytesToEnd); + + // move the current packet to our list of packets + _packets.push_back(std::move(_currentPacket)); + + // recursively call our writeData method for the remaining data to write to a new packet + return numBytesToEnd + writeData(data + numBytesToEnd, maxSize - numBytesToEnd); + } + } +} + +void PacketList::closeCurrentPacket() { + // move the current packet to our list of packets + _packets.push_back(std::move(_currentPacket)); +} diff --git a/libraries/networking/src/udt/PacketList.h b/libraries/networking/src/udt/PacketList.h index 4dc8eb2225..cbd2870ed8 100644 --- a/libraries/networking/src/udt/PacketList.h +++ b/libraries/networking/src/udt/PacketList.h @@ -12,4 +12,62 @@ #ifndef hifi_PacketList_h #define hifi_PacketList_h +#include + +#include "PacketHeaders.h" + +class Packet; + +class PacketList : public QIODevice { + Q_OBJECT +public: + PacketList(PacketType::Value packetType); + + virtual bool isSequential() const { return true; } + + void startSegment(); + void endSegment(); + + PacketType::Value getType() const { return _packetType; } + int getNumPackets() const { return _packets.size() + (_currentPacket ? 1 : 0); } + + void closeCurrentPacket(); + + void setExtendedHeader(const QByteArray& extendedHeader) { _extendedHeader = extendedHeader; } + + template qint64 readPrimitive(T* data); + template qint64 writePrimitive(const T& data); +protected: + virtual qint64 writeData(const char* data, qint64 maxSize); + virtual qint64 readData(char* data, qint64 maxSize) { return 0; } + +private: + friend class LimitedNodeList; + + PacketList(const PacketList& other) = delete; + PacketList& operator=(const PacketList& other) = delete; + + virtual std::unique_ptr createPacket(); + std::unique_ptr createPacketWithExtendedHeader(); + + PacketType::Value _packetType; + bool _isOrdered = false; + + std::unique_ptr _currentPacket; + std::list> _packets; + + int _segmentStartIndex = -1; + + QByteArray _extendedHeader; +}; + +template qint64 PacketList::readPrimitive(T* data) { + return QIODevice::read(reinterpret_cast(data), sizeof(T)); +} + +template qint64 PacketList::writePrimitive(const T& data) { + static_assert(!std::is_pointer::value, "T must not be a pointer"); + return QIODevice::write(reinterpret_cast(&data), sizeof(T)); +} + #endif // hifi_PacketList_h \ No newline at end of file From 81ad0056c3d5f03fa8d3d1ccb7b35637f4d0c498 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 13 Jul 2015 15:34:37 -0700 Subject: [PATCH 08/13] Fix a few node deref --- assignment-client/src/avatars/AvatarMixer.cpp | 2 +- .../src/octree/OctreeInboundPacketProcessor.cpp | 2 +- domain-server/src/DomainServer.cpp | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index 4e5f7f91d4..32371122ee 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -337,7 +337,7 @@ void AvatarMixer::broadcastAvatarData() { }); // send the avatar data PacketList - nodeList->sendPacketList(avatarPacketList, node); + nodeList->sendPacketList(avatarPacketList, *node); // record the bytes sent for other avatar data in the AvatarMixerClientData nodeData->recordSentAvatarData(numAvatarDataBytes); diff --git a/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp b/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp index ebc18162d9..521c4bce46 100644 --- a/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp +++ b/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp @@ -287,7 +287,7 @@ int OctreeInboundPacketProcessor::sendNackPackets() { packetsSent += nackPacketList.getNumPackets(); // send the list of nack packets - nodeList->sendPacketList(nackPacketList, destinationNode); + nodeList->sendPacketList(nackPacketList, *destinationNode); } } diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 9cdac34c30..20eb2c9ac4 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -974,7 +974,7 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif } // write the PacketList to this node - limitedNodeList->sendPacketList(domainListPackets, node); + limitedNodeList->sendPacketList(domainListPackets, *node); } QUuid DomainServer::connectionSecretForNodes(const SharedNodePointer& nodeA, const SharedNodePointer& nodeB) { @@ -1094,7 +1094,7 @@ void DomainServer::readAvailableDatagrams() { assignmentStream << uniqueAssignment; - limitedNodeList->sendUnreliablePacket(*assignmentPacket, *senderSockAddr); + limitedNodeList->sendUnreliablePacket(*assignmentPacket, senderSockAddr); // add the information for that deployed assignment to the hash of pending assigned nodes PendingAssignedNodeData* pendingNodeData = new PendingAssignedNodeData(assignmentToDeploy->getUUID(), @@ -1125,7 +1125,7 @@ void DomainServer::readAvailableDatagrams() { dtlsRequiredPacket->writePrimitive(dtlsPort); } - limitedNodeList->sendUnreliablePacket(*dtlsRequiredPacket, *senderSockAddr); + limitedNodeList->sendUnreliablePacket(*dtlsRequiredPacket, senderSockAddr); } } } From c05105e2f9d556358d529c5798e03edb10f22fd7 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 14 Jul 2015 15:29:49 -0700 Subject: [PATCH 09/13] Added takeFront method to PacketList --- libraries/networking/src/LimitedNodeList.cpp | 6 ++---- libraries/networking/src/udt/PacketList.h | 13 +++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index d54fbd093b..005499cc53 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -288,10 +288,8 @@ qint64 LimitedNodeList::sendPacketList(NLPacketList& packetList, const Node& des qint64 LimitedNodeList::sendPacketList(NLPacketList& packetList, const HifiSockAddr& sockAddr) { qint64 bytesSent{ 0 }; - auto& packets = packetList._packets; - while (!packets.empty()) { - bytesSent += sendPacket(std::move(packets.front()), sockAddr); - packets.pop_front(); + while (!packetList._packets.empty()) { + bytesSent += sendPacket(std::move(packetList.takeFront()), sockAddr); } return bytesSent; diff --git a/libraries/networking/src/udt/PacketList.h b/libraries/networking/src/udt/PacketList.h index cbd2870ed8..173e8c75fb 100644 --- a/libraries/networking/src/udt/PacketList.h +++ b/libraries/networking/src/udt/PacketList.h @@ -47,6 +47,10 @@ private: PacketList(const PacketList& other) = delete; PacketList& operator=(const PacketList& other) = delete; + // Takes the first packet of the list and returns it. + template std::unique_ptr takeFront(); + + // Creates a new packet, can be overriden to change return underlying type virtual std::unique_ptr createPacket(); std::unique_ptr createPacketWithExtendedHeader(); @@ -62,6 +66,7 @@ private: }; template qint64 PacketList::readPrimitive(T* data) { + static_assert(!std::is_pointer::value, "T must not be a pointer"); return QIODevice::read(reinterpret_cast(data), sizeof(T)); } @@ -70,4 +75,12 @@ template qint64 PacketList::writePrimitive(const T& data) { return QIODevice::write(reinterpret_cast(&data), sizeof(T)); } +template std::unique_ptr PacketList::takeFront() { + static_assert(std::is_base_of::value, "T must derive from Packet."); + + auto packet = std::move(_packets.front()); + _packets.pop_front(); + return std::move(std::unique_ptr(dynamic_cast(packet.release()))); +} + #endif // hifi_PacketList_h \ No newline at end of file From fd1648c0d7efb2203b8f55bbda0e6ef949d2b807 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 14 Jul 2015 15:30:41 -0700 Subject: [PATCH 10/13] Code cleanup --- libraries/networking/src/LimitedNodeList.cpp | 2 +- libraries/networking/src/LimitedNodeList.h | 2 -- libraries/networking/src/udt/Packet.cpp | 37 ++++++++++---------- libraries/networking/src/udt/PacketHeaders.h | 1 + 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 005499cc53..677dab7a03 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -275,7 +275,7 @@ qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const Node& } qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const HifiSockAddr& sockAddr) { - return writeDatagram(packet->getData(), sockAddr); + return writeDatagram({packet->getData(), static_cast(packet->getSizeWithHeader())}, sockAddr); } qint64 LimitedNodeList::sendPacketList(NLPacketList& packetList, const Node& destinationNode) { diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index 3d9f85aa08..64fa6daae0 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -42,8 +42,6 @@ #include "NLPacketList.h" #include "UUIDHasher.h" -const int MAX_PACKET_SIZE = 1450; - const quint64 NODE_SILENCE_THRESHOLD_MSECS = 2 * 1000; extern const char SOLO_NODE_TYPES[2]; diff --git a/libraries/networking/src/udt/Packet.cpp b/libraries/networking/src/udt/Packet.cpp index f7a52b068a..f5253a0628 100644 --- a/libraries/networking/src/udt/Packet.cpp +++ b/libraries/networking/src/udt/Packet.cpp @@ -11,8 +11,6 @@ #include "Packet.h" -#include "../LimitedNodeList.h" - qint64 Packet::localHeaderSize(PacketType::Value type) { qint64 size = numBytesForArithmeticCodedPacketType(type) + sizeof(PacketVersion) + ((SEQUENCE_NUMBERED_PACKETS.contains(type)) ? sizeof(SequenceNumber) : 0); @@ -44,23 +42,24 @@ Packet::Packet(PacketType::Value type, qint64 size) : _packetSize(localHeaderSize(_type) + size), _packet(new char(_packetSize)), _payloadStart(_packet.get() + localHeaderSize(_type)), - _capacity(size) { - auto maxPayload = maxPayloadSize(type); - if (size == -1) { - // default size of -1, means biggest packet possible - size = maxPayload; - } - - // Sanity check - Q_ASSERT(size >= 0 || size < maxPayload); - - // copy packet type and version in header - writePacketTypeAndVersion(type); - - // Set control bit and sequence number to 0 if necessary - if (SEQUENCE_NUMBERED_PACKETS.contains(type)) { - writeSequenceNumber(0); - } + _capacity(size) +{ + auto maxPayload = maxPayloadSize(type); + if (size == -1) { + // default size of -1, means biggest packet possible + size = maxPayload; + } + + // Sanity check + Q_ASSERT(size >= 0 || size < maxPayload); + + // copy packet type and version in header + writePacketTypeAndVersion(type); + + // Set control bit and sequence number to 0 if necessary + if (SEQUENCE_NUMBERED_PACKETS.contains(type)) { + writeSequenceNumber(0); + } } Packet::Packet(const Packet& other) { diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index 0108e3e03a..317fafec46 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -83,6 +83,7 @@ namespace PacketType { ICEPingReply }; }; +const int MAX_PACKET_SIZE = 1450; typedef char PacketVersion; From 774a0626b374fcc31a3d00dd6ec356ed9b79ac81 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 14 Jul 2015 15:36:56 -0700 Subject: [PATCH 11/13] Bump all packet version --- .../networking/src/udt/PacketHeaders.cpp | 44 +++++++++---------- libraries/networking/src/udt/PacketHeaders.h | 1 + 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index bea061ae74..b329125896 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -66,48 +66,48 @@ PacketVersion versionForPacketType(PacketType::Value packetType) { switch (packetType) { case MicrophoneAudioNoEcho: case MicrophoneAudioWithEcho: - return 2; + return 3; case SilentAudioFrame: - return 4; + return 5; case MixedAudio: - return 1; - case InjectAudio: - return 1; - case AvatarData: - return 6; - case AvatarIdentity: - return 1; - case EnvironmentData: return 2; + case InjectAudio: + return 2; + case AvatarData: + return 7; + case AvatarIdentity: + return 2; + case EnvironmentData: + return 3; case DomainList: case DomainListRequest: - return 5; + return 6; case DomainConnectRequest: - return 1; + return 2; case CreateAssignment: case RequestAssignment: - return 2; + return 3; case OctreeStats: - return 1; + return 2; case OctreeDataNack: - return 1; + return 2; case StopNode: - return 1; + return 2; case EntityAdd: case EntityEdit: case EntityData: - return VERSION_ENTITIES_HAVE_SIMULATION_OWNER_AND_ACTIONS_OVER_WIRE; + return VERSION_ENTITIES_NEW_PROTOCOL_LAYER; case EntityEditNack: - return 1; - case EntityErase: return 2; + case EntityErase: + return 3; case AudioStreamStats: - return 1; + return 2; case ICEServerHeartbeat: case ICEServerQuery: - return 1; + return 2; default: - return 0; + return 1; } } diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index 317fafec46..d072d3831f 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -168,5 +168,6 @@ const PacketVersion VERSION_ENTITIES_FACE_CAMERA = 30; const PacketVersion VERSION_ENTITIES_SCRIPT_TIMESTAMP = 31; const PacketVersion VERSION_ENTITIES_SCRIPT_TIMESTAMP_FIX = 32; const PacketVersion VERSION_ENTITIES_HAVE_SIMULATION_OWNER_AND_ACTIONS_OVER_WIRE = 33; +const PacketVersion VERSION_ENTITIES_NEW_PROTOCOL_LAYER = 34; #endif // hifi_PacketHeaders_h From aca759aa2f04065db1cc29020f05d3cf01858112 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 14 Jul 2015 16:03:42 -0700 Subject: [PATCH 12/13] Implement brodcastToNodes --- libraries/networking/src/LimitedNodeList.cpp | 22 ++++++++++++++++++-- libraries/networking/src/LimitedNodeList.h | 5 +++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 677dab7a03..98d690a029 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -234,6 +234,11 @@ qint64 LimitedNodeList::readDatagram(QByteArray& incomingPacket, QHostAddress* a return result; } + +qint64 LimitedNodeList::writeDatagram(const NLPacket& packet, const HifiSockAddr& destinationSockAddr) { + return writeDatagram({packet.getData(), static_cast(packet.getSizeWithHeader())}, destinationSockAddr); +} + qint64 LimitedNodeList::writeDatagram(const QByteArray& datagram, const HifiSockAddr& destinationSockAddr) { // XXX can BandwidthRecorder be used for this? // stat collection for packets @@ -261,7 +266,7 @@ qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const Node& } qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr) { - return writeDatagram(packet.getData(), sockAddr); + return writeDatagram(packet, sockAddr); } qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const Node& destinationNode) { @@ -275,7 +280,7 @@ qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const Node& } qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const HifiSockAddr& sockAddr) { - return writeDatagram({packet->getData(), static_cast(packet->getSizeWithHeader())}, sockAddr); + return writeDatagram(*packet, sockAddr); } qint64 LimitedNodeList::sendPacketList(NLPacketList& packetList, const Node& destinationNode) { @@ -519,6 +524,19 @@ std::unique_ptr LimitedNodeList::constructICEPingReplyPacket(const QBy return icePingReplyPacket; } +unsigned int LimitedNodeList::broadcastToNodes(std::unique_ptr packet, const NodeSet& destinationNodeTypes) { + unsigned int n = 0; + + eachNode([&](const SharedNodePointer& node){ + if (destinationNodeTypes.contains(node->getType())) { + writeDatagram(*packet, *node->getActiveSocket()); + ++n; + } + }); + + return n; +} + SharedNodePointer LimitedNodeList::soloNodeOfType(char nodeType) { return nodeMatchingPredicate([&](const SharedNodePointer& node){ return node->getType() == nodeType; diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index 64fa6daae0..f60319f97d 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -153,7 +153,7 @@ public: int updateNodeWithDataFromPacket(const SharedNodePointer& matchingNode, const QByteArray& packet); int findNodeAndUpdateWithDataFromPacket(const QByteArray& packet); - unsigned broadcastToNodes(std::unique_ptr packet, const NodeSet& destinationNodeTypes) { assert(false); return 0; } + unsigned int broadcastToNodes(std::unique_ptr packet, const NodeSet& destinationNodeTypes); SharedNodePointer soloNodeOfType(char nodeType); void getPacketStats(float &packetsPerSecond, float &bytesPerSecond); @@ -254,7 +254,8 @@ protected: LimitedNodeList(unsigned short socketListenPort = 0, unsigned short dtlsListenPort = 0); LimitedNodeList(LimitedNodeList const&); // Don't implement, needed to avoid copies of singleton void operator=(LimitedNodeList const&); // Don't implement, needed to avoid copies of singleton - + + qint64 writeDatagram(const NLPacket& packet, const HifiSockAddr& destinationSockAddr); qint64 writeDatagram(const QByteArray& datagram, const HifiSockAddr& destinationSockAddr); PacketSequenceNumber getNextSequenceNumberForPacket(const QUuid& nodeUUID, PacketType::Value packetType); From 02e1eaf45294ac92282f7e46edcf625d3c0e48b5 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 14 Jul 2015 17:08:36 -0700 Subject: [PATCH 13/13] Merge fixes --- libraries/networking/src/LimitedNodeList.cpp | 14 -------------- libraries/networking/src/NodeList.cpp | 2 +- libraries/networking/src/PacketReceiver.h | 2 +- libraries/networking/src/udt/Packet.h | 2 +- 4 files changed, 3 insertions(+), 17 deletions(-) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 311d95030e..f474b1766b 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -208,20 +208,6 @@ bool LimitedNodeList::packetSourceAndHashMatch(const NLPacket& packet, SharedNod return false; } -qint64 LimitedNodeList::readDatagram(QByteArray& incomingPacket, QHostAddress* address = 0, quint16* port = 0) { - qint64 result = getNodeSocket().readDatagram(incomingPacket.data(), incomingPacket.size(), address, port); - - SharedNodePointer sendingNode = sendingNodeForPacket(incomingPacket); - if (sendingNode) { - emit dataReceived(sendingNode->getType(), incomingPacket.size()); - } else { - emit dataReceived(NodeType::Unassigned, incomingPacket.size()); - } - - return result; -} - - qint64 LimitedNodeList::writeDatagram(const NLPacket& packet, const HifiSockAddr& destinationSockAddr) { return writeDatagram({packet.getData(), static_cast(packet.getSizeWithHeader())}, destinationSockAddr); } diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 5d25654f2d..69dc1052ac 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -170,7 +170,7 @@ void NodeList::processPingPacket(QSharedPointer packet, SharedNodePoin // send back a reply auto replyPacket = constructPingReplyPacket(*packet); const HifiSockAddr& senderSockAddr = packet->getSenderSockAddr(); - sendPacket(std::move(replyPacket), sendingNode, senderSockAddr); + sendPacket(std::move(replyPacket), *sendingNode, senderSockAddr); // If we don't have a symmetric socket for this node and this socket doesn't match // what we have for public and local then set it as the symmetric. diff --git a/libraries/networking/src/PacketReceiver.h b/libraries/networking/src/PacketReceiver.h index f0066115e0..3d4cd18946 100644 --- a/libraries/networking/src/PacketReceiver.h +++ b/libraries/networking/src/PacketReceiver.h @@ -20,7 +20,7 @@ #include #include "NLPacket.h" -#include "PacketHeaders.h" +#include "udt/PacketHeaders.h" class PacketListener; diff --git a/libraries/networking/src/udt/Packet.h b/libraries/networking/src/udt/Packet.h index dfd98b6726..3d64c814aa 100644 --- a/libraries/networking/src/udt/Packet.h +++ b/libraries/networking/src/udt/Packet.h @@ -16,7 +16,7 @@ #include -#include "HifiSockAddr.h" +#include "../HifiSockAddr.h" #include "PacketHeaders.h" class Packet : public QIODevice {