mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 05:52:31 +02:00
Move domain settings retrieval to UDT
This commit is contained in:
parent
62eaaed9e5
commit
63d0205d1e
9 changed files with 58 additions and 15 deletions
|
@ -289,6 +289,9 @@ void DomainServer::setupNodeListAndAssignments(const QUuid& sessionUUID) {
|
||||||
packetReceiver.registerListener(PacketType::ICEPing, this, "processICEPingPacket");
|
packetReceiver.registerListener(PacketType::ICEPing, this, "processICEPingPacket");
|
||||||
packetReceiver.registerListener(PacketType::ICEPingReply, this, "processICEPingReplyPacket");
|
packetReceiver.registerListener(PacketType::ICEPingReply, this, "processICEPingReplyPacket");
|
||||||
packetReceiver.registerListener(PacketType::ICEServerPeerInformation, this, "processICEPeerInformationPacket");
|
packetReceiver.registerListener(PacketType::ICEServerPeerInformation, this, "processICEPeerInformationPacket");
|
||||||
|
|
||||||
|
// NodeList won't be available to the settings manager when it is created, so call registerListener here
|
||||||
|
packetReceiver.registerListener(PacketType::DomainSettingsRequest, &_settingsManager, "processSettingsRequestPacket");
|
||||||
|
|
||||||
// add whatever static assignments that have been parsed to the queue
|
// add whatever static assignments that have been parsed to the queue
|
||||||
addStaticAssignmentsToQueue();
|
addStaticAssignmentsToQueue();
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <Assignment.h>
|
#include <Assignment.h>
|
||||||
#include <HifiConfigVariantMap.h>
|
#include <HifiConfigVariantMap.h>
|
||||||
#include <HTTPConnection.h>
|
#include <HTTPConnection.h>
|
||||||
|
#include <NLPacketList.h>
|
||||||
|
|
||||||
#include "DomainServerSettingsManager.h"
|
#include "DomainServerSettingsManager.h"
|
||||||
|
|
||||||
|
@ -66,6 +67,23 @@ DomainServerSettingsManager::DomainServerSettingsManager() :
|
||||||
QMetaObject::invokeMethod(QCoreApplication::instance(), "quit", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(QCoreApplication::instance(), "quit", Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DomainServerSettingsManager::processSettingsRequestPacket(QSharedPointer<NLPacket> packet) {
|
||||||
|
qDebug() << "Got request for domain settings";
|
||||||
|
|
||||||
|
Assignment::Type type;
|
||||||
|
packet->readPrimitive(&type);
|
||||||
|
|
||||||
|
QJsonObject responseObject = responseObjectForType(QString::number(type));
|
||||||
|
auto json = QJsonDocument(responseObject).toJson();
|
||||||
|
|
||||||
|
auto packetList = std::unique_ptr<NLPacketList>(new NLPacketList(PacketType::DomainSettings, QByteArray(), true, true));
|
||||||
|
|
||||||
|
packetList->write(json);
|
||||||
|
|
||||||
|
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
|
nodeList->sendPacketList(std::move(packetList), packet->getSenderSockAddr());
|
||||||
|
}
|
||||||
|
|
||||||
void DomainServerSettingsManager::setupConfigMap(const QStringList& argumentList) {
|
void DomainServerSettingsManager::setupConfigMap(const QStringList& argumentList) {
|
||||||
_configMap.loadMasterAndUserConfig(argumentList);
|
_configMap.loadMasterAndUserConfig(argumentList);
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#include <HifiConfigVariantMap.h>
|
#include <HifiConfigVariantMap.h>
|
||||||
#include <HTTPManager.h>
|
#include <HTTPManager.h>
|
||||||
|
|
||||||
|
#include <NLPacket.h>
|
||||||
|
|
||||||
const QString SETTINGS_PATHS_KEY = "paths";
|
const QString SETTINGS_PATHS_KEY = "paths";
|
||||||
|
|
||||||
const QString SETTINGS_PATH = "/settings";
|
const QString SETTINGS_PATH = "/settings";
|
||||||
|
@ -38,6 +40,10 @@ public:
|
||||||
|
|
||||||
QVariantMap& getUserSettingsMap() { return _configMap.getUserConfig(); }
|
QVariantMap& getUserSettingsMap() { return _configMap.getUserConfig(); }
|
||||||
QVariantMap& getSettingsMap() { return _configMap.getMergedConfig(); }
|
QVariantMap& getSettingsMap() { return _configMap.getMergedConfig(); }
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void processSettingsRequestPacket(QSharedPointer<NLPacket> packet);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QJsonObject responseObjectForType(const QString& typeValue, bool isAuthenticated = false);
|
QJsonObject responseObjectForType(const QString& typeValue, bool isAuthenticated = false);
|
||||||
void recurseJSONObjectAndOverwriteSettings(const QJsonObject& postedObject, QVariantMap& settingsVariant);
|
void recurseJSONObjectAndOverwriteSettings(const QJsonObject& postedObject, QVariantMap& settingsVariant);
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Assignment : public NodeData {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum Type {
|
enum Type : uint8_t {
|
||||||
AudioMixerType = 0,
|
AudioMixerType = 0,
|
||||||
AvatarMixerType = 1,
|
AvatarMixerType = 1,
|
||||||
AgentType = 2,
|
AgentType = 2,
|
||||||
|
|
|
@ -17,7 +17,9 @@
|
||||||
#include "Assignment.h"
|
#include "Assignment.h"
|
||||||
#include "HifiSockAddr.h"
|
#include "HifiSockAddr.h"
|
||||||
#include "NodeList.h"
|
#include "NodeList.h"
|
||||||
|
#include "udt/Packet.h"
|
||||||
#include "udt/PacketHeaders.h"
|
#include "udt/PacketHeaders.h"
|
||||||
|
#include "NLPacket.h"
|
||||||
#include "SharedUtil.h"
|
#include "SharedUtil.h"
|
||||||
#include "UserActivityLogger.h"
|
#include "UserActivityLogger.h"
|
||||||
#include "NetworkLogging.h"
|
#include "NetworkLogging.h"
|
||||||
|
@ -39,7 +41,7 @@ DomainHandler::DomainHandler(QObject* parent) :
|
||||||
_failedSettingsRequests(0)
|
_failedSettingsRequests(0)
|
||||||
{
|
{
|
||||||
_sockAddr.setObjectName("DomainServer");
|
_sockAddr.setObjectName("DomainServer");
|
||||||
|
|
||||||
// if we get a socket that make sure our NetworkPeer ping timer stops
|
// if we get a socket that make sure our NetworkPeer ping timer stops
|
||||||
connect(this, &DomainHandler::completedSocketDiscovery, &_icePeer, &NetworkPeer::stopPingTimer);
|
connect(this, &DomainHandler::completedSocketDiscovery, &_icePeer, &NetworkPeer::stopPingTimer);
|
||||||
}
|
}
|
||||||
|
@ -233,21 +235,15 @@ void DomainHandler::requestDomainSettings() {
|
||||||
emit settingsReceived(_settingsObject);
|
emit settingsReceived(_settingsObject);
|
||||||
} else {
|
} else {
|
||||||
if (_settingsObject.isEmpty()) {
|
if (_settingsObject.isEmpty()) {
|
||||||
// setup the URL required to grab settings JSON
|
qCDebug(networking) << "Requesting settings from domain server";
|
||||||
QUrl settingsJSONURL;
|
|
||||||
settingsJSONURL.setScheme("http");
|
|
||||||
settingsJSONURL.setHost(_hostname);
|
|
||||||
settingsJSONURL.setPort(DOMAIN_SERVER_HTTP_PORT);
|
|
||||||
settingsJSONURL.setPath("/settings.json");
|
|
||||||
Assignment::Type assignmentType = Assignment::typeForNodeType(DependencyManager::get<NodeList>()->getOwnerType());
|
Assignment::Type assignmentType = Assignment::typeForNodeType(DependencyManager::get<NodeList>()->getOwnerType());
|
||||||
settingsJSONURL.setQuery(QString("type=%1").arg(assignmentType));
|
|
||||||
|
|
||||||
qCDebug(networking) << "Requesting domain-server settings at" << settingsJSONURL.toString();
|
auto packet = NLPacket::create(PacketType::DomainSettingsRequest, sizeof(assignmentType), true, false);
|
||||||
|
packet->writePrimitive(assignmentType);
|
||||||
|
|
||||||
QNetworkRequest settingsRequest(settingsJSONURL);
|
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
settingsRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
nodeList->sendPacket(std::move(packet), _sockAddr);
|
||||||
QNetworkReply* reply = NetworkAccessManager::getInstance().get(settingsRequest);
|
|
||||||
connect(reply, &QNetworkReply::finished, this, &DomainHandler::settingsRequestFinished);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,6 +282,19 @@ void DomainHandler::settingsRequestFinished() {
|
||||||
settingsReply->deleteLater();
|
settingsReply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DomainHandler::processSettingsPacketList(QSharedPointer<NLPacketList> packetList) {
|
||||||
|
auto data = packetList->getAllData();
|
||||||
|
|
||||||
|
_settingsObject = QJsonDocument::fromJson(data).object();
|
||||||
|
|
||||||
|
qCDebug(networking) << "Received domain settings: \n" << QString(data);
|
||||||
|
|
||||||
|
// reset failed settings requests to 0, we got them
|
||||||
|
_failedSettingsRequests = 0;
|
||||||
|
|
||||||
|
emit settingsReceived(_settingsObject);
|
||||||
|
}
|
||||||
|
|
||||||
void DomainHandler::processICEPingReplyPacket(QSharedPointer<NLPacket> packet) {
|
void DomainHandler::processICEPingReplyPacket(QSharedPointer<NLPacket> packet) {
|
||||||
const HifiSockAddr& senderSockAddr = packet->getSenderSockAddr();
|
const HifiSockAddr& senderSockAddr = packet->getSenderSockAddr();
|
||||||
qCDebug(networking) << "Received reply from domain-server on" << senderSockAddr;
|
qCDebug(networking) << "Received reply from domain-server on" << senderSockAddr;
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include "HifiSockAddr.h"
|
#include "HifiSockAddr.h"
|
||||||
#include "NetworkPeer.h"
|
#include "NetworkPeer.h"
|
||||||
#include "NLPacket.h"
|
#include "NLPacket.h"
|
||||||
|
#include "NLPacketList.h"
|
||||||
|
#include "Node.h"
|
||||||
|
|
||||||
const unsigned short DEFAULT_DOMAIN_SERVER_PORT = 40102;
|
const unsigned short DEFAULT_DOMAIN_SERVER_PORT = 40102;
|
||||||
const unsigned short DEFAULT_DOMAIN_SERVER_DTLS_PORT = 40103;
|
const unsigned short DEFAULT_DOMAIN_SERVER_DTLS_PORT = 40103;
|
||||||
|
@ -85,6 +87,7 @@ public slots:
|
||||||
void setHostnameAndPort(const QString& hostname, quint16 port = DEFAULT_DOMAIN_SERVER_PORT);
|
void setHostnameAndPort(const QString& hostname, quint16 port = DEFAULT_DOMAIN_SERVER_PORT);
|
||||||
void setIceServerHostnameAndID(const QString& iceServerHostname, const QUuid& id);
|
void setIceServerHostnameAndID(const QString& iceServerHostname, const QUuid& id);
|
||||||
|
|
||||||
|
void processSettingsPacketList(QSharedPointer<NLPacketList> packetList);
|
||||||
void processICEPingReplyPacket(QSharedPointer<NLPacket> packet);
|
void processICEPingReplyPacket(QSharedPointer<NLPacket> packet);
|
||||||
void processDTLSRequirementPacket(QSharedPointer<NLPacket> dtlsRequirementPacket);
|
void processDTLSRequirementPacket(QSharedPointer<NLPacket> dtlsRequirementPacket);
|
||||||
void processICEResponsePacket(QSharedPointer<NLPacket> icePacket);
|
void processICEResponsePacket(QSharedPointer<NLPacket> icePacket);
|
||||||
|
|
|
@ -95,6 +95,7 @@ NodeList::NodeList(char newOwnerType, unsigned short socketListenPort, unsigned
|
||||||
packetReceiver.registerListener(PacketType::ICEPing, this, "processICEPingPacket");
|
packetReceiver.registerListener(PacketType::ICEPing, this, "processICEPingPacket");
|
||||||
packetReceiver.registerListener(PacketType::DomainServerAddedNode, this, "processDomainServerAddedNode");
|
packetReceiver.registerListener(PacketType::DomainServerAddedNode, this, "processDomainServerAddedNode");
|
||||||
packetReceiver.registerListener(PacketType::DomainServerConnectionToken, this, "processDomainServerConnectionTokenPacket");
|
packetReceiver.registerListener(PacketType::DomainServerConnectionToken, this, "processDomainServerConnectionTokenPacket");
|
||||||
|
packetReceiver.registerMessageListener(PacketType::DomainSettings, &_domainHandler, "processSettingsPacketList");
|
||||||
packetReceiver.registerListener(PacketType::ICEServerPeerInformation, &_domainHandler, "processICEResponsePacket");
|
packetReceiver.registerListener(PacketType::ICEServerPeerInformation, &_domainHandler, "processICEResponsePacket");
|
||||||
packetReceiver.registerListener(PacketType::DomainServerRequireDTLS, &_domainHandler, "processDTLSRequirementPacket");
|
packetReceiver.registerListener(PacketType::DomainServerRequireDTLS, &_domainHandler, "processDTLSRequirementPacket");
|
||||||
packetReceiver.registerListener(PacketType::ICEPingReply, &_domainHandler, "processICEPingReplyPacket");
|
packetReceiver.registerListener(PacketType::ICEPingReply, &_domainHandler, "processICEPingReplyPacket");
|
||||||
|
|
|
@ -26,6 +26,7 @@ const QSet<PacketType> NON_SOURCED_PACKETS = QSet<PacketType>()
|
||||||
<< PacketType::DomainList << PacketType::DomainConnectionDenied
|
<< PacketType::DomainList << PacketType::DomainConnectionDenied
|
||||||
<< PacketType::DomainServerPathQuery << PacketType::DomainServerPathResponse
|
<< PacketType::DomainServerPathQuery << PacketType::DomainServerPathResponse
|
||||||
<< PacketType::DomainServerAddedNode
|
<< PacketType::DomainServerAddedNode
|
||||||
|
<< PacketType::DomainSettingsRequest << PacketType::DomainSettings
|
||||||
<< PacketType::ICEServerPeerInformation << PacketType::ICEServerQuery << PacketType::ICEServerHeartbeat
|
<< PacketType::ICEServerPeerInformation << PacketType::ICEServerQuery << PacketType::ICEServerHeartbeat
|
||||||
<< PacketType::ICEPing << PacketType::ICEPingReply
|
<< PacketType::ICEPing << PacketType::ICEPingReply
|
||||||
<< PacketType::AssignmentClientStatus << PacketType::StopNode;
|
<< PacketType::AssignmentClientStatus << PacketType::StopNode;
|
||||||
|
|
|
@ -71,7 +71,9 @@ enum class PacketType : uint8_t {
|
||||||
EntityAdd,
|
EntityAdd,
|
||||||
EntityErase,
|
EntityErase,
|
||||||
EntityEdit,
|
EntityEdit,
|
||||||
DomainServerConnectionToken
|
DomainServerConnectionToken,
|
||||||
|
DomainSettingsRequest,
|
||||||
|
DomainSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
const int NUM_BYTES_MD5_HASH = 16;
|
const int NUM_BYTES_MD5_HASH = 16;
|
||||||
|
|
Loading…
Reference in a new issue