change packet type to be sourced, change from packet list to single packet

This commit is contained in:
Liv 2017-07-25 20:17:20 -07:00
parent 9458e4a1eb
commit 57b27a7bb7
4 changed files with 13 additions and 19 deletions

View file

@ -928,7 +928,7 @@ void OctreeServer::handleJurisdictionRequestPacket(QSharedPointer<ReceivedMessag
void OctreeServer::handleOctreeFileReplacement(QSharedPointer<ReceivedMessage> message) {
if (!_isFinished && !_isShuttingDown) {
// these messages are only allowed to come from the domain server or authenticated users, so make sure that is the case
// these messages are only allowed to come from the domain server, so make sure that is the case
auto nodeList = DependencyManager::get<NodeList>();
if (message->getSenderSockAddr() == nodeList->getDomainHandler().getSockAddr()) {
// it's far cleaner to load up the new content upon server startup
@ -965,8 +965,7 @@ void OctreeServer::handleOctreeFileReplacement(QSharedPointer<ReceivedMessage> m
} else {
qWarning() << "Could not write replacement octree data to file - refusing to process";
}
}
else {
} else {
qDebug() << "Received replacement octree file that is invalid - refusing to process";
}
} else {
@ -984,6 +983,7 @@ void OctreeServer::handleOctreeFileReplacementFromURL(QSharedPointer<ReceivedMes
if (!_isFinished && !_isShuttingDown) {
// This call comes from Interface, so we skip our domain server check
// but confirm that we have permissions to replace content sets
if (DependencyManager::get<NodeList>()->getThisNodeCanReplaceContent()) {
if (!_persistAbsoluteFilePath.isEmpty()) {
// Convert message data into our URL
QString url(message->getMessage());
@ -1020,23 +1020,20 @@ void OctreeServer::handleOctreeFileReplacementFromURL(QSharedPointer<ReceivedMes
// process it when it comes back up
qInfo() << "Wrote octree replacement file to" << replacementFilePath << "- stopping server";
setFinished(true);
}
else {
} else {
qWarning() << "Could not write replacement octree data to file - refusing to process";
}
}
else {
} else {
qDebug() << "Received replacement octree file that is invalid - refusing to process";
}
}
else {
} else {
qDebug() << "Error downloading JSON from specified file";
}
});
}
else {
} else {
qDebug() << "Cannot perform octree file replacement since current persist file path is not yet known";
}
}
}
}

View file

@ -255,7 +255,7 @@ static const QString DESKTOP_DISPLAY_PLUGIN_NAME = "Desktop";
static const QString SYSTEM_TABLET = "com.highfidelity.interface.tablet.system";
const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensions{
const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensions {
{ SVO_EXTENSION, &Application::importSVOFromURL },
{ SVO_JSON_EXTENSION, &Application::importSVOFromURL },
{ AVA_JSON_EXTENSION, &Application::askToWearAvatarAttachmentUrl },
@ -6070,9 +6070,9 @@ bool Application::askToReplaceDomainContent(const QString& url) {
limitedNodeList->eachMatchingNode([](const SharedNodePointer& node) {
return node->getType() == NodeType::EntityServer && node->getActiveSocket();
}, [&_url, limitedNodeList](const SharedNodePointer& octreeNode) {
auto octreeFilePacketList = NLPacketList::create(PacketType::OctreeFileReplacementFromUrl, QByteArray(), true, true);
octreeFilePacketList->write(_url);
limitedNodeList->sendPacketList(std::move(octreeFilePacketList), *octreeNode);
auto octreeFilePacket = NLPacket::create(PacketType::OctreeFileReplacementFromUrl, _url.size(), true);
octreeFilePacket->write(_url);
limitedNodeList->sendPacket(std::move(octreeFilePacket), *octreeNode);
return true;
});
}

View file

@ -311,8 +311,6 @@ signals:
void uploadRequest(QString path);
void receivedHifiSchemeURL(const QString& url);
void requestDomainContentReplacement(const QString& url);
public slots:
QVector<EntityItemID> pasteEntities(float x, float y, float z);
bool exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs, const glm::vec3* givenOffset = nullptr);

View file

@ -42,8 +42,7 @@ const QSet<PacketType> NON_SOURCED_PACKETS = QSet<PacketType>()
<< PacketType::DomainServerRemovedNode << PacketType::UsernameFromIDReply << PacketType::OctreeFileReplacement
<< PacketType::ReplicatedMicrophoneAudioNoEcho << PacketType::ReplicatedMicrophoneAudioWithEcho
<< PacketType::ReplicatedInjectAudio << PacketType::ReplicatedSilentAudioFrame
<< PacketType::ReplicatedAvatarIdentity << PacketType::ReplicatedKillAvatar << PacketType::ReplicatedBulkAvatarData
<< PacketType::OctreeFileReplacementFromUrl;
<< PacketType::ReplicatedAvatarIdentity << PacketType::ReplicatedKillAvatar << PacketType::ReplicatedBulkAvatarData;
const QHash<PacketType, PacketType> REPLICATED_PACKET_MAPPING {
{ PacketType::MicrophoneAudioNoEcho, PacketType::ReplicatedMicrophoneAudioNoEcho },