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>();
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver();
packetReceiver.registerListenerForTypes({
//PacketType::EntityAdd,
packetReceiver.registerListenerForTypes({ PacketType::EntityAdd,
PacketType::EntityEdit,
PacketType::EntityErase,
PacketType::EntityPhysics,
@ -52,9 +51,6 @@ EntityServer::EntityServer(ReceivedMessage& message) :
this,
"handleEntityPacket");
packetReceiver.registerListener(PacketType::EntityAdd, this, "handleEntityPacket");
connect(&_dynamicDomainVerificationTimer, &QTimer::timeout, this, &EntityServer::startDynamicDomainVerification);
_dynamicDomainVerificationTimer.setSingleShot(true);
}
@ -76,13 +72,6 @@ void EntityServer::aboutToFinish() {
}
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) {
_octreeInboundPacketProcessor->queueReceivedPacket(message, senderNode);
}

View file

@ -76,20 +76,12 @@ void OctreeInboundPacketProcessor::midProcess() {
}
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) {
qDebug() << "OctreeInboundPacketProcessor::processPacket() while shutting down... ignoring incoming packet";
return;
}
bool debugProcessPacket = true; // _myServer->wantsVerboseDebug();
bool debugProcessPacket = _myServer->wantsVerboseDebug();
if (debugProcessPacket) {
qDebug("OctreeInboundPacketProcessor::processPacket() payload=%p payloadLength=%lld",

View file

@ -81,9 +81,6 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type,
EntityTreePointer entityTree,
EntityItemID entityItemID,
const EntityItemProperties& properties) {
qDebug() << __FUNCTION__ << "type:" << type;
if (!_shouldSend) {
return; // bail early
}
@ -97,13 +94,10 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type,
QByteArray bufferOut(NLPacket::maxPayloadSize(type), 0);
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);
}
qDebug() << __FUNCTION__ << "bufferOut.size():" << bufferOut.size();
OctreeElement::AppendState encodeResult = OctreeElement::PARTIAL; // start the loop assuming there's more to send
auto nodeList = DependencyManager::get<NodeList>();
@ -127,8 +121,6 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type,
qCDebug(entities) << " properties:" << properties;
#endif
qDebug() << __FUNCTION__ << "about to call queueOctreeEditMessage() --- bufferOut.size():" << bufferOut.size();
queueOctreeEditMessage(type, bufferOut);
if (type == PacketType::EntityAdd && !properties.getCertificateID().isEmpty()) {
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* 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
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());
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()) {
buffer.replace(0, finalizedSize, finalizedData, finalizedSize);
buffer.resize(finalizedSize);
qDebug() << __FUNCTION__ << "replaced with finalized data size:" << buffer.size();
} else {
qCDebug(entities) << "ERROR - encoded edit message doesn't fit in output buffer.";
success = false;

View file

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

View file

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

View file

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

View file

@ -25,15 +25,6 @@ void ReceivedPacketProcessor::terminating() {
}
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();
_packets.push_back({ sendingNode, message });
_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
// a known nodeID.
void OctreeEditPacketSender::queuePacketListToNode(const QUuid& nodeUUID, std::unique_ptr<NLPacketList> packetList) {
qDebug() << __FUNCTION__ << "to:" << nodeUUID << "type:" << packetList->getType() << "size:" << packetList->getDataSize();
bool wantDebug = false;
DependencyManager::get<NodeList>()->eachNode([&](const SharedNodePointer& node) {
// only send to the NodeTypes that are getMyNodeType()
@ -129,10 +126,7 @@ void OctreeEditPacketSender::queuePacketListToNode(const QUuid& nodeUUID, std::u
&& node->getActiveSocket()) {
// NOTE: unlike packets, the packet lists don't get rewritten sequence numbers.
// add packet to history -- we don't keep track of sent PacketLists
//_sentPacketHistories[nodeUUID].packetSent(sequence, *packet);
// or do history for resend
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) {
qDebug() << __FUNCTION__ << "to:" << nodeID << "type:" << packetList->getType() << "size:" << packetList->getDataSize();
_releaseQueuedPacketMutex.lock();
if (packetList->getMessageSize() > 0 && packetList->getType() != PacketType::Unknown) {
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) {
_enableCompression = enableCompression;
_targetSize = targetSize; // std::min(MAX_OCTREE_UNCOMRESSED_PACKET_SIZE, targetSize);
_targetSize = targetSize;
_uncompressedByteArray.resize(_targetSize);
_compressedByteArray.resize(_targetSize);

View file

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