From bd10cd6fa9336bfc82d4dab338eed928bac8eeb6 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 20 Mar 2018 10:53:17 -0700 Subject: [PATCH] 'disconnect' from serverless domain when transitioning from a serverless-domain to a DNS name (rather than a place name) --- interface/src/Application.cpp | 21 +++++++++++++++------ interface/src/Application.h | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 05d140775f..d493ab88b0 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3118,6 +3118,9 @@ bool Application::isServerlessMode() const { void Application::setIsServerlessDomain(bool serverlessDomain) { auto tree = getEntities()->getTree(); + if (tree->isServerlessMode() && !serverlessDomain) { + disconnectFromDomain(); + } if (tree) { tree->setIsServerlessMode(serverlessDomain); } @@ -3129,12 +3132,7 @@ void Application::loadServerlessDomain(QUrl domainURL) { return; } - auto nodeList = DependencyManager::get(); - clearDomainOctreeDetails(); - getMyAvatar()->setSessionUUID(QUuid()); // clear the sessionID - NodePermissions permissions; // deny all permissions - permissions.setAll(false); - nodeList->setPermissions(permissions); + disconnectFromDomain(); if (domainURL.isEmpty()) { return; @@ -3142,9 +3140,11 @@ void Application::loadServerlessDomain(QUrl domainURL) { QUuid serverlessSessionID = QUuid::createUuid(); getMyAvatar()->setSessionUUID(serverlessSessionID); + auto nodeList = DependencyManager::get(); nodeList->setSessionUUID(serverlessSessionID); // there is no domain-server to tell us our permissions, so enable all + NodePermissions permissions; permissions.setAll(true); nodeList->setPermissions(permissions); @@ -3164,6 +3164,15 @@ void Application::loadServerlessDomain(QUrl domainURL) { _fullSceneReceivedCounter++; } +void Application::disconnectFromDomain() { + auto nodeList = DependencyManager::get(); + clearDomainOctreeDetails(); + getMyAvatar()->setSessionUUID(QUuid()); // clear the sessionID + NodePermissions permissions; // deny all permissions + permissions.setAll(false); + nodeList->setPermissions(permissions); +} + bool Application::importImage(const QString& urlString) { qCDebug(interfaceapp) << "An image file has been dropped in"; QString filepath(urlString); diff --git a/interface/src/Application.h b/interface/src/Application.h index 4c31eb0074..6c34fca5db 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -392,6 +392,7 @@ public slots: void setIsServerlessDomain(bool serverlessDomain); void loadServerlessDomain(QUrl domainURL); + void disconnectFromDomain(); Q_INVOKABLE bool askBeforeSetAvatarUrl(const QString& avatarUrl) { return askToSetAvatarUrl(avatarUrl); }