mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 04:13:11 +02:00
support specification of named landing-points in serverless-domain json files
This commit is contained in:
parent
4dcab95b40
commit
f81836c830
7 changed files with 61 additions and 11 deletions
|
@ -3146,6 +3146,9 @@ void Application::loadServerlessDomain(QUrl domainURL) {
|
||||||
tmpTree->sendEntities(&_entityEditSender, getEntities()->getTree(), 0, 0, 0);
|
tmpTree->sendEntities(&_entityEditSender, getEntities()->getTree(), 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<QString, QString> namedPaths = tmpTree->getNamedPaths();
|
||||||
|
nodeList->getDomainHandler().setIsConnected(true, namedPaths);
|
||||||
|
|
||||||
_fullSceneReceivedCounter++;
|
_fullSceneReceivedCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2303,6 +2303,18 @@ bool EntityTree::readFromMap(QVariantMap& map) {
|
||||||
_persistDataVersion = map["DataVersion"].toInt();
|
_persistDataVersion = map["DataVersion"].toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_namedPaths.clear();
|
||||||
|
if (map.contains("Paths")) {
|
||||||
|
QVariantMap namedPathsMap = map["Paths"].toMap();
|
||||||
|
for(QVariantMap::const_iterator iter = namedPathsMap.begin(); iter != namedPathsMap.end(); ++iter) {
|
||||||
|
QString namedPathName = iter.key();
|
||||||
|
QString namedPathViewPoint = iter.value().toString();
|
||||||
|
_namedPaths[namedPathName] = namedPathViewPoint;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_namedPaths["/"] = "/";
|
||||||
|
}
|
||||||
|
|
||||||
// map will have a top-level list keyed as "Entities". This will be extracted
|
// map will have a top-level list keyed as "Entities". This will be extracted
|
||||||
// and iterated over. Each member of this list is converted to a QVariantMap, then
|
// and iterated over. Each member of this list is converted to a QVariantMap, then
|
||||||
// to a QScriptValue, and then to EntityItemProperties. These properties are used
|
// to a QScriptValue, and then to EntityItemProperties. These properties are used
|
||||||
|
|
|
@ -301,6 +301,8 @@ public:
|
||||||
static bool addMaterialToOverlay(const QUuid& overlayID, graphics::MaterialLayer material, const std::string& parentMaterialName);
|
static bool addMaterialToOverlay(const QUuid& overlayID, graphics::MaterialLayer material, const std::string& parentMaterialName);
|
||||||
static bool removeMaterialFromOverlay(const QUuid& overlayID, graphics::MaterialPointer material, const std::string& parentMaterialName);
|
static bool removeMaterialFromOverlay(const QUuid& overlayID, graphics::MaterialPointer material, const std::string& parentMaterialName);
|
||||||
|
|
||||||
|
std::map<QString, QString> getNamedPaths() const { return _namedPaths; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deletingEntity(const EntityItemID& entityID);
|
void deletingEntity(const EntityItemID& entityID);
|
||||||
void deletingEntityPointer(EntityItem* entityID);
|
void deletingEntityPointer(EntityItem* entityID);
|
||||||
|
@ -417,6 +419,8 @@ private:
|
||||||
static std::function<bool(const QUuid&, graphics::MaterialPointer, const std::string&)> _removeMaterialFromOverlayOperator;
|
static std::function<bool(const QUuid&, graphics::MaterialPointer, const std::string&)> _removeMaterialFromOverlayOperator;
|
||||||
|
|
||||||
bool _serverlessDomain { false };
|
bool _serverlessDomain { false };
|
||||||
|
|
||||||
|
std::map<QString, QString> _namedPaths;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_EntityTree_h
|
#endif // hifi_EntityTree_h
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include "UserActivityLogger.h"
|
#include "UserActivityLogger.h"
|
||||||
#include "udt/PacketHeaders.h"
|
#include "udt/PacketHeaders.h"
|
||||||
|
|
||||||
const QString DEFAULT_HIFI_ADDRESS = "file:///~/serverless/tutorial.json";
|
const QString DEFAULT_HIFI_ADDRESS = "file:///~/serverless/tutorial.json?location=/";
|
||||||
const QString ADDRESS_MANAGER_SETTINGS_GROUP = "AddressManager";
|
const QString ADDRESS_MANAGER_SETTINGS_GROUP = "AddressManager";
|
||||||
const QString SETTINGS_CURRENT_ADDRESS_KEY = "address";
|
const QString SETTINGS_CURRENT_ADDRESS_KEY = "address";
|
||||||
|
|
||||||
|
@ -312,7 +312,15 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
|
||||||
_shareablePlaceName.clear();
|
_shareablePlaceName.clear();
|
||||||
setDomainInfo(lookupUrl, trigger);
|
setDomainInfo(lookupUrl, trigger);
|
||||||
emit lookupResultsFinished();
|
emit lookupResultsFinished();
|
||||||
handlePath(DOMAIN_SPAWNING_POINT, LookupTrigger::Internal, false);
|
|
||||||
|
QString path = DOMAIN_SPAWNING_POINT;
|
||||||
|
QUrlQuery queryArgs(lookupUrl);
|
||||||
|
const QString LOCATION_QUERY_KEY = "location";
|
||||||
|
if (queryArgs.hasQueryItem(LOCATION_QUERY_KEY)) {
|
||||||
|
path = queryArgs.queryItemValue(LOCATION_QUERY_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
handlePath(path, LookupTrigger::Internal, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,9 +173,7 @@ void DomainHandler::setURLAndID(QUrl domainURL, QUuid domainID) {
|
||||||
QString previousHost = _domainURL.host();
|
QString previousHost = _domainURL.host();
|
||||||
_domainURL = domainURL;
|
_domainURL = domainURL;
|
||||||
|
|
||||||
if (domainURL.scheme() != URL_SCHEME_HIFI) {
|
if (previousHost != domainURL.host()) {
|
||||||
setIsConnected(true);
|
|
||||||
} else if (previousHost != domainURL.host()) {
|
|
||||||
qCDebug(networking) << "Updated domain hostname to" << domainURL.host();
|
qCDebug(networking) << "Updated domain hostname to" << domainURL.host();
|
||||||
|
|
||||||
if (!domainURL.host().isEmpty()) {
|
if (!domainURL.host().isEmpty()) {
|
||||||
|
@ -250,6 +248,14 @@ void DomainHandler::activateICEPublicSocket() {
|
||||||
emit completedSocketDiscovery();
|
emit completedSocketDiscovery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString DomainHandler::getViewPointFromNamedPath(QString namedPath) {
|
||||||
|
auto lookup = _namedPaths.find(namedPath);
|
||||||
|
if (lookup != _namedPaths.end()) {
|
||||||
|
return lookup->second;
|
||||||
|
}
|
||||||
|
return DOMAIN_SPAWNING_POINT;
|
||||||
|
}
|
||||||
|
|
||||||
void DomainHandler::completedHostnameLookup(const QHostInfo& hostInfo) {
|
void DomainHandler::completedHostnameLookup(const QHostInfo& hostInfo) {
|
||||||
for (int i = 0; i < hostInfo.addresses().size(); i++) {
|
for (int i = 0; i < hostInfo.addresses().size(); i++) {
|
||||||
if (hostInfo.addresses()[i].protocol() == QAbstractSocket::IPv4Protocol) {
|
if (hostInfo.addresses()[i].protocol() == QAbstractSocket::IPv4Protocol) {
|
||||||
|
@ -279,7 +285,8 @@ void DomainHandler::completedIceServerHostnameLookup() {
|
||||||
emit iceSocketAndIDReceived();
|
emit iceSocketAndIDReceived();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainHandler::setIsConnected(bool isConnected) {
|
void DomainHandler::setIsConnected(bool isConnected, std::map<QString, QString> namedPaths) {
|
||||||
|
_namedPaths = namedPaths;
|
||||||
if (_isConnected != isConnected) {
|
if (_isConnected != isConnected) {
|
||||||
_isConnected = isConnected;
|
_isConnected = isConnected;
|
||||||
|
|
||||||
|
|
|
@ -73,9 +73,11 @@ public:
|
||||||
void activateICEPublicSocket();
|
void activateICEPublicSocket();
|
||||||
|
|
||||||
bool isConnected() const { return _isConnected; }
|
bool isConnected() const { return _isConnected; }
|
||||||
void setIsConnected(bool isConnected);
|
void setIsConnected(bool isConnected, std::map<QString, QString> namedPaths = std::map<QString, QString>());
|
||||||
bool isServerless() const { return _domainURL.scheme() != URL_SCHEME_HIFI; }
|
bool isServerless() const { return _domainURL.scheme() != URL_SCHEME_HIFI; }
|
||||||
|
|
||||||
|
QString getViewPointFromNamedPath(QString namedPath);
|
||||||
|
|
||||||
bool hasSettings() const { return !_settingsObject.isEmpty(); }
|
bool hasSettings() const { return !_settingsObject.isEmpty(); }
|
||||||
void requestDomainSettings();
|
void requestDomainSettings();
|
||||||
const QJsonObject& getSettingsObject() const { return _settingsObject; }
|
const QJsonObject& getSettingsObject() const { return _settingsObject; }
|
||||||
|
@ -200,6 +202,8 @@ private:
|
||||||
int _checkInPacketsSinceLastReply { 0 };
|
int _checkInPacketsSinceLastReply { 0 };
|
||||||
|
|
||||||
QTimer _apiRefreshTimer;
|
QTimer _apiRefreshTimer;
|
||||||
|
|
||||||
|
std::map<QString, QString> _namedPaths;
|
||||||
};
|
};
|
||||||
|
|
||||||
const QString DOMAIN_SPAWNING_POINT { "/0, -10, 0" };
|
const QString DOMAIN_SPAWNING_POINT { "/0, -10, 0" };
|
||||||
|
|
|
@ -413,7 +413,14 @@ void NodeList::sendDomainServerCheckIn() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::handleDSPathQuery(const QString& newPath) {
|
void NodeList::handleDSPathQuery(const QString& newPath) {
|
||||||
if (_domainHandler.isSocketKnown()) {
|
if (_domainHandler.isServerless()) {
|
||||||
|
if (_domainHandler.isConnected()) {
|
||||||
|
auto viewpoint = _domainHandler.getViewPointFromNamedPath(newPath);
|
||||||
|
DependencyManager::get<AddressManager>()->goToViewpointForPath(viewpoint, newPath);
|
||||||
|
} else {
|
||||||
|
_domainHandler.setPendingPath(newPath);
|
||||||
|
}
|
||||||
|
} else if (_domainHandler.isSocketKnown()) {
|
||||||
// if we have a DS socket we assume it will get this packet and send if off right away
|
// if we have a DS socket we assume it will get this packet and send if off right away
|
||||||
sendDSPathQuery(newPath);
|
sendDSPathQuery(newPath);
|
||||||
} else {
|
} else {
|
||||||
|
@ -427,10 +434,15 @@ void NodeList::sendPendingDSPathQuery() {
|
||||||
QString pendingPath = _domainHandler.getPendingPath();
|
QString pendingPath = _domainHandler.getPendingPath();
|
||||||
|
|
||||||
if (!pendingPath.isEmpty()) {
|
if (!pendingPath.isEmpty()) {
|
||||||
qCDebug(networking) << "Attempting to send pending query to DS for path" << pendingPath;
|
|
||||||
|
|
||||||
// this is a slot triggered if we just established a network link with a DS and want to send a path query
|
if (_domainHandler.isServerless()) {
|
||||||
sendDSPathQuery(_domainHandler.getPendingPath());
|
auto viewpoint = _domainHandler.getViewPointFromNamedPath(pendingPath);
|
||||||
|
DependencyManager::get<AddressManager>()->goToViewpointForPath(viewpoint, pendingPath);
|
||||||
|
} else {
|
||||||
|
qCDebug(networking) << "Attempting to send pending query to DS for path" << pendingPath;
|
||||||
|
// this is a slot triggered if we just established a network link with a DS and want to send a path query
|
||||||
|
sendDSPathQuery(_domainHandler.getPendingPath());
|
||||||
|
}
|
||||||
|
|
||||||
// clear whatever the pending path was
|
// clear whatever the pending path was
|
||||||
_domainHandler.clearPendingPath();
|
_domainHandler.clearPendingPath();
|
||||||
|
|
Loading…
Reference in a new issue