This commit is contained in:
ZappoMan 2017-11-17 13:03:04 -08:00
parent cd0fa989e1
commit 71a46a3374
11 changed files with 9 additions and 102 deletions

View file

@ -41,8 +41,7 @@ EntityServer::EntityServer(ReceivedMessage& message) :
DependencyManager::set<ScriptCache>(); DependencyManager::set<ScriptCache>();
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver(); auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver();
packetReceiver.registerListenerForTypes({ packetReceiver.registerListenerForTypes({ PacketType::EntityAdd,
//PacketType::EntityAdd,
PacketType::EntityEdit, PacketType::EntityEdit,
PacketType::EntityErase, PacketType::EntityErase,
PacketType::EntityPhysics, PacketType::EntityPhysics,
@ -52,9 +51,6 @@ EntityServer::EntityServer(ReceivedMessage& message) :
this, this,
"handleEntityPacket"); "handleEntityPacket");
packetReceiver.registerListener(PacketType::EntityAdd, this, "handleEntityPacket");
connect(&_dynamicDomainVerificationTimer, &QTimer::timeout, this, &EntityServer::startDynamicDomainVerification); connect(&_dynamicDomainVerificationTimer, &QTimer::timeout, this, &EntityServer::startDynamicDomainVerification);
_dynamicDomainVerificationTimer.setSingleShot(true); _dynamicDomainVerificationTimer.setSingleShot(true);
} }
@ -76,13 +72,6 @@ void EntityServer::aboutToFinish() {
} }
void EntityServer::handleEntityPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode) { void EntityServer::handleEntityPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode) {
qDebug() << __FUNCTION__ << "from:" << senderNode->getUUID() << "type:" << message->getType()
<< "getNumPackets:" << message->getNumPackets()
<< "getSize:" << message->getSize()
<< "isFromPacketList:" << message->isFromPacketList()
<< "isComplete:" << message->isComplete()
;
if (_octreeInboundPacketProcessor) { if (_octreeInboundPacketProcessor) {
_octreeInboundPacketProcessor->queueReceivedPacket(message, senderNode); _octreeInboundPacketProcessor->queueReceivedPacket(message, senderNode);
} }

View file

@ -76,20 +76,12 @@ void OctreeInboundPacketProcessor::midProcess() {
} }
void OctreeInboundPacketProcessor::processPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) { void OctreeInboundPacketProcessor::processPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
qDebug() << __FUNCTION__ << "from:" << sendingNode->getUUID() << "type:" << message->getType()
<< "getNumPackets:" << message->getNumPackets()
<< "getSize:" << message->getSize()
<< "isFromPacketList:" << message->isFromPacketList()
<< "isComplete:" << message->isComplete()
;
if (_shuttingDown) { if (_shuttingDown) {
qDebug() << "OctreeInboundPacketProcessor::processPacket() while shutting down... ignoring incoming packet"; qDebug() << "OctreeInboundPacketProcessor::processPacket() while shutting down... ignoring incoming packet";
return; return;
} }
bool debugProcessPacket = true; // _myServer->wantsVerboseDebug(); bool debugProcessPacket = _myServer->wantsVerboseDebug();
if (debugProcessPacket) { if (debugProcessPacket) {
qDebug("OctreeInboundPacketProcessor::processPacket() payload=%p payloadLength=%lld", qDebug("OctreeInboundPacketProcessor::processPacket() payload=%p payloadLength=%lld",

View file

@ -81,9 +81,6 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type,
EntityTreePointer entityTree, EntityTreePointer entityTree,
EntityItemID entityItemID, EntityItemID entityItemID,
const EntityItemProperties& properties) { const EntityItemProperties& properties) {
qDebug() << __FUNCTION__ << "type:" << type;
if (!_shouldSend) { if (!_shouldSend) {
return; // bail early return; // bail early
} }
@ -97,13 +94,10 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type,
QByteArray bufferOut(NLPacket::maxPayloadSize(type), 0); QByteArray bufferOut(NLPacket::maxPayloadSize(type), 0);
if (type == PacketType::EntityAdd) { if (type == PacketType::EntityAdd) {
auto MAX_ADD_DATA_SIZE = NLPacket::maxPayloadSize(type) * 10; // a really big packet auto MAX_ADD_DATA_SIZE = NLPacket::maxPayloadSize(type) * 10; // a really big buffer
bufferOut.resize(MAX_ADD_DATA_SIZE); bufferOut.resize(MAX_ADD_DATA_SIZE);
} }
qDebug() << __FUNCTION__ << "bufferOut.size():" << bufferOut.size();
OctreeElement::AppendState encodeResult = OctreeElement::PARTIAL; // start the loop assuming there's more to send OctreeElement::AppendState encodeResult = OctreeElement::PARTIAL; // start the loop assuming there's more to send
auto nodeList = DependencyManager::get<NodeList>(); auto nodeList = DependencyManager::get<NodeList>();
@ -127,8 +121,6 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type,
qCDebug(entities) << " properties:" << properties; qCDebug(entities) << " properties:" << properties;
#endif #endif
qDebug() << __FUNCTION__ << "about to call queueOctreeEditMessage() --- bufferOut.size():" << bufferOut.size();
queueOctreeEditMessage(type, bufferOut); queueOctreeEditMessage(type, bufferOut);
if (type == PacketType::EntityAdd && !properties.getCertificateID().isEmpty()) { if (type == PacketType::EntityAdd && !properties.getCertificateID().isEmpty()) {
emit addingEntityWithCertificate(properties.getCertificateID(), DependencyManager::get<AddressManager>()->getPlaceName()); emit addingEntityWithCertificate(properties.getCertificateID(), DependencyManager::get<AddressManager>()->getPlaceName());

View file

@ -1227,9 +1227,6 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy
OctreePacketData ourDataPacket(false, buffer.size()); // create a packetData object to add out packet details too. OctreePacketData ourDataPacket(false, buffer.size()); // create a packetData object to add out packet details too.
OctreePacketData* packetData = &ourDataPacket; // we want a pointer to this so we can use our APPEND_ENTITY_PROPERTY macro OctreePacketData* packetData = &ourDataPacket; // we want a pointer to this so we can use our APPEND_ENTITY_PROPERTY macro
qDebug() << __FUNCTION__ << "OctreePacketData::getBytesAvailable():" << packetData->getBytesAvailable();
bool success = true; // assume the best bool success = true; // assume the best
OctreeElement::AppendState appendState = OctreeElement::COMPLETED; // assume the best OctreeElement::AppendState appendState = OctreeElement::COMPLETED; // assume the best
@ -1528,15 +1525,9 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy
const char* finalizedData = reinterpret_cast<const char*>(packetData->getFinalizedData()); const char* finalizedData = reinterpret_cast<const char*>(packetData->getFinalizedData());
int finalizedSize = packetData->getFinalizedSize(); int finalizedSize = packetData->getFinalizedSize();
qDebug() << __FUNCTION__ << "packetData->getFinalizedSize():" << packetData->getFinalizedSize();
qDebug() << __FUNCTION__ << "packetData->getUncompressedSize():" << packetData->getUncompressedSize();
qDebug() << __FUNCTION__ << "buffer.size():" << buffer.size();
if (finalizedSize <= buffer.size()) { if (finalizedSize <= buffer.size()) {
buffer.replace(0, finalizedSize, finalizedData, finalizedSize); buffer.replace(0, finalizedSize, finalizedData, finalizedSize);
buffer.resize(finalizedSize); buffer.resize(finalizedSize);
qDebug() << __FUNCTION__ << "replaced with finalized data size:" << buffer.size();
} else { } else {
qCDebug(entities) << "ERROR - encoded edit message doesn't fit in output buffer."; qCDebug(entities) << "ERROR - encoded edit message doesn't fit in output buffer.";
success = false; success = false;

View file

@ -64,9 +64,6 @@ void PacketSender::queuePacketListForSending(const SharedNodePointer& destinatio
_totalPacketsQueued += packetList->getNumPackets(); _totalPacketsQueued += packetList->getNumPackets();
_totalBytesQueued += packetList->getMessageSize(); _totalBytesQueued += packetList->getMessageSize();
qDebug() << __FUNCTION__ << "to:" << destinationNode->getUUID() << "type:" << packetList->getType() << "size:" << packetList->getDataSize()
<< "_totalPacketsQueued:" << _totalPacketsQueued << "_totalBytesQueued:" << _totalBytesQueued;
lock(); lock();
_packets.push_back({ destinationNode, PacketOrPacketList { nullptr, std::move(packetList)} }); _packets.push_back({ destinationNode, PacketOrPacketList { nullptr, std::move(packetList)} });
unlock(); unlock();
@ -293,16 +290,9 @@ bool PacketSender::nonThreadedProcess() {
size_t packetCount = sendAsPacket ? 1 : packetPair.second.second->getNumPackets(); size_t packetCount = sendAsPacket ? 1 : packetPair.second.second->getNumPackets();
if (sendAsPacket) { if (sendAsPacket) {
qDebug() << __FUNCTION__ << "sendUnreliablePacket() to:" << packetPair.first->getUUID() << "type:" << packetPair.second.first->getType();
DependencyManager::get<NodeList>()->sendUnreliablePacket(*packetPair.second.first, *packetPair.first); DependencyManager::get<NodeList>()->sendUnreliablePacket(*packetPair.second.first, *packetPair.first);
} else { } else {
DependencyManager::get<NodeList>()->sendPacketList(std::move(packetPair.second.second), *packetPair.first);
qDebug() << __FUNCTION__ << "sendPacketList() to:" << packetPair.first->getUUID() << "type:" << packetPair.second.second->getType()
<< "getMessageSize:" << packetPair.second.second->getMessageSize()
<< "getDataSize:" << packetPair.second.second->getDataSize();
DependencyManager::get<NodeList>()->sendPacketList(*packetPair.second.second, *packetPair.first);
} }
@ -313,13 +303,6 @@ bool PacketSender::nonThreadedProcess() {
_totalBytesSent += packetSize; _totalBytesSent += packetSize;
emit packetSent(packetSize); // FIXME should include number of packets? emit packetSent(packetSize); // FIXME should include number of packets?
qDebug() << __FUNCTION__ << "packetsSentThisCall:" << packetsSentThisCall
<< "_packetsOverCheckInterval:" << _packetsOverCheckInterval
<< "_totalPacketsSent:" << _totalPacketsSent
<< "packetSize:" << packetSize
<< "_totalBytesSent:" << _totalBytesSent;
_lastSendTime = now; _lastSendTime = now;
} }
return isStillRunning(); return isStillRunning();

View file

@ -26,10 +26,8 @@ ReceivedMessage::ReceivedMessage(const NLPacketList& packetList)
_sourceID(packetList.getSourceID()), _sourceID(packetList.getSourceID()),
_packetType(packetList.getType()), _packetType(packetList.getType()),
_packetVersion(packetList.getVersion()), _packetVersion(packetList.getVersion()),
_senderSockAddr(packetList.getSenderSockAddr()), _senderSockAddr(packetList.getSenderSockAddr())
_fromPacketList(true)
{ {
qDebug() << __FUNCTION__ << "(const NLPacketList& packetList) _fromPacketList:" << _fromPacketList;
} }
ReceivedMessage::ReceivedMessage(NLPacket& packet) ReceivedMessage::ReceivedMessage(NLPacket& packet)
@ -40,12 +38,8 @@ ReceivedMessage::ReceivedMessage(NLPacket& packet)
_packetType(packet.getType()), _packetType(packet.getType()),
_packetVersion(packet.getVersion()), _packetVersion(packet.getVersion()),
_senderSockAddr(packet.getSenderSockAddr()), _senderSockAddr(packet.getSenderSockAddr()),
_isComplete(packet.getPacketPosition() == NLPacket::ONLY), _isComplete(packet.getPacketPosition() == NLPacket::ONLY)
_fromPacket(true)
{ {
if (packet.getType() == PacketType::EntityAdd) {
qDebug() << __FUNCTION__ << "(NLPacket& packet) _fromPacketList:" << _fromPacketList << "packet.getType():" << packet.getType();
}
} }
ReceivedMessage::ReceivedMessage(QByteArray byteArray, PacketType packetType, PacketVersion packetVersion, ReceivedMessage::ReceivedMessage(QByteArray byteArray, PacketType packetType, PacketVersion packetVersion,
@ -57,10 +51,8 @@ ReceivedMessage::ReceivedMessage(QByteArray byteArray, PacketType packetType, Pa
_packetType(packetType), _packetType(packetType),
_packetVersion(packetVersion), _packetVersion(packetVersion),
_senderSockAddr(senderSockAddr), _senderSockAddr(senderSockAddr),
_isComplete(true), _isComplete(true)
_fromByteArray(true)
{ {
qDebug() << __FUNCTION__ << "(QByteArray byteArray)... _fromPacketList:" << _fromPacketList;
} }
void ReceivedMessage::setFailed() { void ReceivedMessage::setFailed() {

View file

@ -79,10 +79,6 @@ public:
template<typename T> qint64 readHeadPrimitive(T* data); template<typename T> qint64 readHeadPrimitive(T* data);
bool isFromPacketList() const { return _fromPacketList; };
bool isFromPacket() const { return _fromPacket; };
bool isFromByteArray() const { return _fromByteArray; };
signals: signals:
void progress(qint64 size); void progress(qint64 size);
void completed(); void completed();
@ -104,12 +100,6 @@ private:
std::atomic<bool> _isComplete { true }; std::atomic<bool> _isComplete { true };
std::atomic<bool> _failed { false }; std::atomic<bool> _failed { false };
std::atomic<bool> _fromPacketList { false };
std::atomic<bool> _fromPacket { false };
std::atomic<bool> _fromByteArray { false };
}; };
Q_DECLARE_METATYPE(ReceivedMessage*) Q_DECLARE_METATYPE(ReceivedMessage*)

View file

@ -25,15 +25,6 @@ void ReceivedPacketProcessor::terminating() {
} }
void ReceivedPacketProcessor::queueReceivedPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) { void ReceivedPacketProcessor::queueReceivedPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
qDebug() << __FUNCTION__ << "from:" << sendingNode->getUUID() << "type:" << message->getType()
<< "getNumPackets:" << message->getNumPackets()
<< "getSize:" << message->getSize()
<< "isFromPacketList:" << message->isFromPacketList()
<< "isComplete:" << message->isComplete()
;
lock(); lock();
_packets.push_back({ sendingNode, message }); _packets.push_back({ sendingNode, message });
_nodePacketCounts[sendingNode->getUUID()]++; _nodePacketCounts[sendingNode->getUUID()]++;

View file

@ -118,9 +118,6 @@ void OctreeEditPacketSender::queuePacketToNode(const QUuid& nodeUUID, std::uniqu
// This method is called when the edit packet layer has determined that it has a fully formed packet destined for // This method is called when the edit packet layer has determined that it has a fully formed packet destined for
// a known nodeID. // a known nodeID.
void OctreeEditPacketSender::queuePacketListToNode(const QUuid& nodeUUID, std::unique_ptr<NLPacketList> packetList) { void OctreeEditPacketSender::queuePacketListToNode(const QUuid& nodeUUID, std::unique_ptr<NLPacketList> packetList) {
qDebug() << __FUNCTION__ << "to:" << nodeUUID << "type:" << packetList->getType() << "size:" << packetList->getDataSize();
bool wantDebug = false; bool wantDebug = false;
DependencyManager::get<NodeList>()->eachNode([&](const SharedNodePointer& node) { DependencyManager::get<NodeList>()->eachNode([&](const SharedNodePointer& node) {
// only send to the NodeTypes that are getMyNodeType() // only send to the NodeTypes that are getMyNodeType()
@ -129,10 +126,7 @@ void OctreeEditPacketSender::queuePacketListToNode(const QUuid& nodeUUID, std::u
&& node->getActiveSocket()) { && node->getActiveSocket()) {
// NOTE: unlike packets, the packet lists don't get rewritten sequence numbers. // NOTE: unlike packets, the packet lists don't get rewritten sequence numbers.
// or do history for resend
// add packet to history -- we don't keep track of sent PacketLists
//_sentPacketHistories[nodeUUID].packetSent(sequence, *packet);
queuePacketListForSending(node, std::move(packetList)); queuePacketListForSending(node, std::move(packetList));
} }
}); });
@ -380,9 +374,6 @@ void OctreeEditPacketSender::releaseQueuedPacket(const QUuid& nodeID, std::uniqu
} }
void OctreeEditPacketSender::releaseQueuedPacketList(const QUuid& nodeID, std::unique_ptr<NLPacketList> packetList) { void OctreeEditPacketSender::releaseQueuedPacketList(const QUuid& nodeID, std::unique_ptr<NLPacketList> packetList) {
qDebug() << __FUNCTION__ << "to:" << nodeID << "type:" << packetList->getType() << "size:" << packetList->getDataSize();
_releaseQueuedPacketMutex.lock(); _releaseQueuedPacketMutex.lock();
if (packetList->getMessageSize() > 0 && packetList->getType() != PacketType::Unknown) { if (packetList->getMessageSize() > 0 && packetList->getType() != PacketType::Unknown) {
queuePacketListToNode(nodeID, std::move(packetList)); queuePacketListToNode(nodeID, std::move(packetList));

View file

@ -35,8 +35,7 @@ OctreePacketData::OctreePacketData(bool enableCompression, int targetSize) {
void OctreePacketData::changeSettings(bool enableCompression, unsigned int targetSize) { void OctreePacketData::changeSettings(bool enableCompression, unsigned int targetSize) {
_enableCompression = enableCompression; _enableCompression = enableCompression;
_targetSize = targetSize; // std::min(MAX_OCTREE_UNCOMRESSED_PACKET_SIZE, targetSize); _targetSize = targetSize;
_uncompressedByteArray.resize(_targetSize); _uncompressedByteArray.resize(_targetSize);
_compressedByteArray.resize(_targetSize); _compressedByteArray.resize(_targetSize);

View file

@ -279,8 +279,6 @@ private:
unsigned int _targetSize; unsigned int _targetSize;
bool _enableCompression; bool _enableCompression;
//unsigned char _uncompressed[MAX_OCTREE_UNCOMRESSED_PACKET_SIZE];
QByteArray _uncompressedByteArray; QByteArray _uncompressedByteArray;
unsigned char* _uncompressed { nullptr }; unsigned char* _uncompressed { nullptr };
int _bytesInUse; int _bytesInUse;
@ -291,7 +289,6 @@ private:
bool compressContent(); bool compressContent();
//unsigned char _compressed[MAX_OCTREE_UNCOMRESSED_PACKET_SIZE];
QByteArray _compressedByteArray; QByteArray _compressedByteArray;
unsigned char* _compressed { nullptr }; unsigned char* _compressed { nullptr };
int _compressedBytes; int _compressedBytes;