Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added metaverse server URL setting in domain server admin panel. #1726

Merged
merged 3 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions assignment-client/src/entities/EntityServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <plugins/PluginManager.h>
#include <EntityEditFilters.h>
#include <NetworkingConstants.h>
#include <MetaverseAPI.h>
#include <hfm/ModelFormatRegistry.h>

#include "../AssignmentDynamicFactory.h"
Expand Down Expand Up @@ -279,7 +278,7 @@ int EntityServer::sendSpecialPackets(const SharedNodePointer& node, OctreeQueryN

#ifdef EXTRA_ERASE_DEBUGGING
if (packetsSent > 0) {
qDebug() << "EntityServer::sendSpecialPackets() sent " << packetsSent << "special packets of "
qDebug() << "EntityServer::sendSpecialPackets() sent " << packetsSent << "special packets of "
<< totalBytes << " total bytes to node:" << node->getUUID();
}
#endif
Expand Down Expand Up @@ -345,14 +344,14 @@ void EntityServer::readAdditionalConfiguration(const QJsonObject& settingsSectio
} else {
tree->setEntityScriptSourceWhitelist("");
}

auto entityEditFilters = DependencyManager::get<EntityEditFilters>();

QString filterURL;
if (readOptionString("entityEditFilter", settingsSectionObject, filterURL) && !filterURL.isEmpty()) {
// connect the filterAdded signal, and block edits until you hear back
connect(entityEditFilters.data(), &EntityEditFilters::filterAdded, this, &EntityServer::entityFilterAdded);

entityEditFilters->addFilter(EntityItemID(), filterURL);
}
}
Expand Down Expand Up @@ -386,7 +385,7 @@ void EntityServer::nodeKilled(SharedNodePointer node) {

// FIXME - this stats tracking is somewhat temporary to debug the Whiteboard issues. It's not a bad
// set of stats to have, but we'd probably want a different data structure if we keep it very long.
// Since this version uses a single shared QMap for all senders, there could be some lock contention
// Since this version uses a single shared QMap for all senders, there could be some lock contention
// on this QWriteLocker
void EntityServer::trackSend(const QUuid& dataID, quint64 dataLastEdited, const QUuid& sessionID) {
QWriteLocker locker(&_viewerSendingStatsLock);
Expand Down
7 changes: 7 additions & 0 deletions domain-server/resources/describe-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
{
"name": "metaverse",
"label": "Networking / Metaverse",
"assignment-types": [ 0, 1, 2, 3, 4, 5, 6 ],
"settings": [
{
"name": "server_url",
"label": "Metaverse Server URL",
"placeholder": "Optional",
"advanced": true
},
{
"name": "access_token",
"label": "Access Token",
Expand Down
6 changes: 6 additions & 0 deletions domain-server/src/DomainServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ DomainServer::DomainServer(int argc, char* argv[]) :
}
_settingsManager.setupConfigMap(userConfigFilename);

auto settingsMetaverseUrl = _settingsManager.valueForKeyPath(MetaverseAPI::Settings::URL_KEY_PATH);
if (settingsMetaverseUrl.isValid()) {
MetaverseAPI::Settings::getInstance()->setSettingsUrl(settingsMetaverseUrl.toString());
}


// setup a shutdown event listener to handle SIGTERM or WM_CLOSE for us
#ifdef _WIN32
installNativeEventFilter(&ShutdownEventListener::getInstance());
Expand Down
9 changes: 4 additions & 5 deletions libraries/entities-renderer/src/RenderableWebEntityItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

#include "EntitiesRendererLogging.h"
#include <NetworkingConstants.h>
#include <MetaverseAPI.h>

using namespace render;
using namespace render::entities;
Expand Down Expand Up @@ -188,7 +187,7 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene

if (_webSurface) {
if (_webSurface->getRootItem()) {
if (_contentType == ContentType::HtmlContent && _sourceURL != newSourceURL) {
if (_contentType == ContentType::HtmlContent && _sourceURL != newSourceURL) {
if (localSafeContext) {
::hifi::scripting::setLocalAccessSafeThread(true);
}
Expand Down Expand Up @@ -226,15 +225,15 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene
}
}

{
{
auto useBackground = entity->getUseBackground();
if (_useBackground != useBackground) {
_webSurface->getRootItem()->setProperty(USE_BACKGROUND_PROPERTY, useBackground);
_useBackground = useBackground;
}
}
{

{
auto userAgent = entity->getUserAgent();
if (_userAgent != userAgent) {
_webSurface->getRootItem()->setProperty(USER_AGENT_PROPERTY, userAgent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#include <NetworkLogging.h>
#include "MaterialNetworkingLogging.h"
#include <NetworkingConstants.h>
#include <MetaverseAPI.h>
#include <Trace.h>
#include <StatTracker.h>

Expand Down
3 changes: 1 addition & 2 deletions libraries/networking/src/AssetUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "NetworkAccessManager.h"
#include "NetworkLogging.h"
#include "NetworkingConstants.h"
#include "MetaverseAPI.h"

#include "ResourceManager.h"

Expand Down Expand Up @@ -93,7 +92,7 @@ bool saveToCache(const QUrl& url, const QByteArray& file) {
}
}
}

return false;
}

Expand Down
3 changes: 1 addition & 2 deletions libraries/networking/src/DomainHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "Node.h"
#include "ReceivedMessage.h"
#include "NetworkingConstants.h"
#include "MetaverseAPI.h"

const unsigned short DEFAULT_DOMAIN_SERVER_PORT =
QProcessEnvironment::systemEnvironment()
Expand Down Expand Up @@ -83,7 +82,7 @@ const quint16 DOMAIN_SERVER_EXPORTER_PORT =
.value("VIRCADIA_DOMAIN_SERVER_EXPORTER_PORT")
.toUInt()
: 9703;

const quint16 DOMAIN_SERVER_METADATA_EXPORTER_PORT =
QProcessEnvironment::systemEnvironment()
.contains("VIRCADIA_DOMAIN_SERVER_METADATA_EXPORTER_PORT")
Expand Down
3 changes: 1 addition & 2 deletions libraries/networking/src/FileResourceRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "NetworkLogging.h"
#include "ResourceManager.h"
#include "NetworkingConstants.h"
#include "MetaverseAPI.h"

void FileResourceRequest::doSend() {
auto statTracker = DependencyManager::get<StatTracker>();
Expand Down Expand Up @@ -85,7 +84,7 @@ void FileResourceRequest::doSend() {
_result = ResourceRequest::NotFound;
}
}

_state = Finished;
emit finished();

Expand Down
40 changes: 36 additions & 4 deletions libraries/networking/src/MetaverseAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//
// Created by Kalila L. on 2019-12-16.
// Copyright 2019, 2022 Vircadia contributors.
// Copyright 2022 DigiSomni LLC.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
Expand All @@ -12,22 +13,46 @@
#include "MetaverseAPI.h"

#include <QUrl>
#include <QDebug>
#include "NetworkingConstants.h"

#include <SettingHandle.h>
#include <DependencyManager.h>

#include "NetworkingConstants.h"
#include "NodeList.h"


namespace MetaverseAPI {

const QString Settings::GROUP = "metaverse";
const QString Settings::URL_KEY = "server_url";
const QString Settings::URL_KEY_PATH = Settings::GROUP + "." + Settings::URL_KEY;

Settings* Settings::getInstance() {
static Settings sharedInstance;
return &sharedInstance;
}

Settings::Settings(QObject* parent) : QObject(parent) { };
Settings::Settings(QObject* parent) : QObject(parent), settingsURL(std::nullopt) { };

const QString BASE_URL_SETTING_KEY = "private/selectedMetaverseURL";

std::optional<QUrl> getMetaverseURLFromDomainHandler() {
if (DependencyManager::isSet<NodeList>()) {
auto&& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
if (domainHandler.hasSettings()) {
auto&& settings = domainHandler.getSettingsObject();
if (settings.contains(Settings::GROUP) &&
settings[Settings::GROUP].isObject() &&
settings[Settings::GROUP].toObject().contains(Settings::URL_KEY) &&
settings[Settings::GROUP][Settings::URL_KEY].isString()) {
return QUrl(settings[Settings::GROUP][Settings::URL_KEY].toString());
}
}
}

return std::nullopt;
}

QUrl Settings::getBaseUrl() {
const QString HIFI_METAVERSE_URL_ENV = "HIFI_METAVERSE_URL";

Expand All @@ -36,7 +61,14 @@ namespace MetaverseAPI {
defaultURL = QUrl(QProcessEnvironment::systemEnvironment().value(HIFI_METAVERSE_URL_ENV));
}

return Setting::Handle<QUrl> (BASE_URL_SETTING_KEY, defaultURL).get();
auto optionalURL = settingsURL ? settingsURL : getMetaverseURLFromDomainHandler();
QUrl settingsURL = optionalURL ? *optionalURL : defaultURL;

return Setting::Handle<QUrl> (BASE_URL_SETTING_KEY, settingsURL).get();
}

void Settings::setSettingsUrl(const QUrl& value) {
settingsURL = value;
}

void Settings::setBaseUrl(const QUrl& value) {
Expand Down
12 changes: 12 additions & 0 deletions libraries/networking/src/MetaverseAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//
// Created by Kalila L. on 2019-12-16.
// Copyright 2019, 2022 Vircadia contributors.
// Copyright 2022 DigiSomni LLC.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
Expand All @@ -12,6 +13,8 @@
#ifndef athena_MetaverseAPI_h
#define athena_MetaverseAPI_h

#include <optional>

#include <QtCore/QProcessEnvironment>
#include <QtCore/QUrl>

Expand All @@ -20,15 +23,24 @@ namespace MetaverseAPI {
class Settings : public QObject {
Q_OBJECT
public:
static const QString GROUP;
static const QString URL_KEY;
static const QString URL_KEY_PATH;

static Settings* getInstance();

void setSettingsUrl(const QUrl& value);

public slots:
QUrl getBaseUrl();
void setBaseUrl(const QUrl& value);


protected:
Settings(QObject* parent = nullptr);

private:
std::optional<QUrl> settingsURL;
};

QUrl getCurrentMetaverseServerURL();
Expand Down
3 changes: 1 addition & 2 deletions libraries/procedural/src/procedural/Procedural.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <NumericalConstants.h>
#include <GLMHelpers.h>
#include <NetworkingConstants.h>
#include <MetaverseAPI.h>
#include <shaders/Shaders.h>

#include "ShaderConstants.h"
Expand Down Expand Up @@ -533,4 +532,4 @@ void graphics::ProceduralMaterial::initializeProcedural() {
// FIXME: Setup proper uniform slots and use correct pipelines for forward rendering
_procedural._opaqueFragmentSource = gpu::Shader::getFragmentShaderSource(shader::render_utils::fragment::simple_procedural);
_procedural._transparentFragmentSource = gpu::Shader::getFragmentShaderSource(shader::render_utils::fragment::simple_procedural_translucent);
}
}
3 changes: 1 addition & 2 deletions libraries/qml/src/qml/OffscreenSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <gl/OffscreenGLCanvas.h>
#include <shared/ReadWriteLockable.h>
#include <NetworkingConstants.h>
#include <MetaverseAPI.h>

#include "Logging.h"
#include "impl/SharedObject.h"
Expand All @@ -35,7 +34,7 @@
using namespace hifi::qml;
using namespace hifi::qml::impl;

QmlUrlValidator OffscreenSurface::validator = [](const QUrl& url) -> bool {
QmlUrlValidator OffscreenSurface::validator = [](const QUrl& url) -> bool {
if (url.isRelative()) {
return true;
}
Expand Down