mirror of
https://github.com/lubosz/overte.git
synced 2025-04-07 02:22:32 +02:00
more consistent variable names. rework DomainManager and AddressManager methods to take a url rather than host and port
This commit is contained in:
parent
3e114f2b55
commit
33065fb51c
17 changed files with 185 additions and 164 deletions
|
@ -339,8 +339,6 @@ static const QString SNAPSHOT_EXTENSION = ".jpg";
|
|||
static const QString JPG_EXTENSION = ".jpg";
|
||||
static const QString PNG_EXTENSION = ".png";
|
||||
static const QString SVO_EXTENSION = ".svo";
|
||||
static const QString SERVERLESS_DOMAIN_EXTENSION = ".domain.json";
|
||||
static const QString SERVERLESS_DOMAIN_GZ_EXTENSION = ".domain.json.gz";
|
||||
static const QString SVO_JSON_EXTENSION = ".svo.json";
|
||||
static const QString JSON_GZ_EXTENSION = ".json.gz";
|
||||
static const QString JSON_EXTENSION = ".json";
|
||||
|
@ -382,8 +380,6 @@ const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensi
|
|||
{ SVO_EXTENSION, &Application::importSVOFromURL },
|
||||
{ SVO_JSON_EXTENSION, &Application::importSVOFromURL },
|
||||
{ AVA_JSON_EXTENSION, &Application::askToWearAvatarAttachmentUrl },
|
||||
{ SERVERLESS_DOMAIN_EXTENSION, &Application::visitServerlessDomain },
|
||||
{ SERVERLESS_DOMAIN_GZ_EXTENSION, &Application::visitServerlessDomain },
|
||||
{ JSON_EXTENSION, &Application::importJSONFromURL },
|
||||
{ JS_EXTENSION, &Application::askToLoadScript },
|
||||
{ FST_EXTENSION, &Application::askToSetAvatarUrl },
|
||||
|
@ -1112,10 +1108,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
|
||||
const DomainHandler& domainHandler = nodeList->getDomainHandler();
|
||||
|
||||
connect(&domainHandler, SIGNAL(hostnameChanged(const QString&)), SLOT(domainChanged(const QString&)));
|
||||
connect(&domainHandler, SIGNAL(serverlessDomainChanged(QUrl)), SLOT(loadServerlessDomain(QUrl)));
|
||||
connect(&domainHandler, SIGNAL(domainURLChanged(QUrl)), SLOT(domainURLChanged(QUrl)));
|
||||
connect(&domainHandler, SIGNAL(resetting()), SLOT(resettingDomain()));
|
||||
connect(&domainHandler, SIGNAL(connectedToDomain(const QString&, const QUrl&)), SLOT(updateWindowTitle()));
|
||||
connect(&domainHandler, SIGNAL(connectedToDomain(QUrl)), SLOT(updateWindowTitle()));
|
||||
connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle()));
|
||||
connect(&domainHandler, &DomainHandler::disconnectedFromDomain, this, &Application::clearDomainAvatars);
|
||||
connect(&domainHandler, &DomainHandler::disconnectedFromDomain, this, [this]() {
|
||||
|
@ -1173,7 +1168,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
connect(addressManager.data(), &AddressManager::hostChanged, this, &Application::updateWindowTitle);
|
||||
connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress);
|
||||
|
||||
connect(addressManager.data(), &AddressManager::setServersEnabled, this, &Application::setServersEnabled);
|
||||
connect(addressManager.data(), &AddressManager::setServerlessDomain, this, &Application::setServerlessDomain);
|
||||
|
||||
connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateThreadPoolCount);
|
||||
connect(this, &Application::activeDisplayPluginChanged, this, [](){
|
||||
|
@ -2075,7 +2070,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
connect(&_addAssetToWorldErrorTimer, &QTimer::timeout, this, &Application::addAssetToWorldErrorTimeout);
|
||||
|
||||
connect(this, &QCoreApplication::aboutToQuit, this, &Application::addAssetToWorldMessageClose);
|
||||
connect(&domainHandler, &DomainHandler::hostnameChanged, this, &Application::addAssetToWorldMessageClose);
|
||||
connect(&domainHandler, &DomainHandler::domainURLChanged, this, &Application::addAssetToWorldMessageClose);
|
||||
|
||||
updateSystemTabletMode();
|
||||
|
||||
|
@ -3104,18 +3099,13 @@ bool Application::importFromZIP(const QString& filePath) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void Application::setServersEnabled(bool serversEnabled) {
|
||||
if (_serversEnabled != serversEnabled) {
|
||||
_serversEnabled = serversEnabled;
|
||||
getEntities()->getTree()->setIsServerlessMode(!_serversEnabled);
|
||||
void Application::setServerlessDomain(bool serverlessDomain) {
|
||||
if (_serverlessDomain != serverlessDomain) {
|
||||
_serverlessDomain = serverlessDomain;
|
||||
getEntities()->getTree()->setIsServerlessMode(_serverlessDomain);
|
||||
}
|
||||
}
|
||||
|
||||
bool Application::visitServerlessDomain(const QString& urlString) {
|
||||
DependencyManager::get<AddressManager>()->handleLookupString(urlString);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Application::loadServerlessDomain(QUrl domainURL) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "loadServerlessDomain", Q_ARG(QUrl, domainURL));
|
||||
|
@ -5798,7 +5788,7 @@ void Application::updateWindowTitle() const {
|
|||
|
||||
QString currentPlaceName;
|
||||
if (isServerlessMode()) {
|
||||
currentPlaceName = "serverless: " + DependencyManager::get<AddressManager>()->getServerlessDomainURL().toString();
|
||||
currentPlaceName = "serverless: " + DependencyManager::get<AddressManager>()->getDomainURL().toString();
|
||||
} else {
|
||||
currentPlaceName = DependencyManager::get<AddressManager>()->getHost();
|
||||
if (currentPlaceName.isEmpty()) {
|
||||
|
@ -5816,7 +5806,7 @@ void Application::updateWindowTitle() const {
|
|||
_window->setWindowTitle(title);
|
||||
|
||||
// updateTitleWindow gets called whenever there's a change regarding the domain, so rather
|
||||
// than placing this within domainChanged, it's placed here to cover the other potential cases.
|
||||
// than placing this within domainURLChanged, it's placed here to cover the other potential cases.
|
||||
DependencyManager::get< MessagesClient >()->sendLocalMessage("Toolbar-DomainChanged", "");
|
||||
}
|
||||
|
||||
|
@ -5855,11 +5845,14 @@ void Application::clearDomainAvatars() {
|
|||
DependencyManager::get<AvatarManager>()->clearOtherAvatars();
|
||||
}
|
||||
|
||||
void Application::domainChanged(const QString& domainHostname) {
|
||||
void Application::domainURLChanged(QUrl domainURL) {
|
||||
clearDomainOctreeDetails();
|
||||
updateWindowTitle();
|
||||
// disable physics until we have enough information about our new location to not cause craziness.
|
||||
resetPhysicsReadyInformation();
|
||||
if (domainURL.scheme() != HIFI_URL_SCHEME) {
|
||||
loadServerlessDomain(domainURL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -285,7 +285,7 @@ public:
|
|||
bool getSaveAvatarOverrideUrl() { return _saveAvatarOverrideUrl; }
|
||||
void saveNextPhysicsStats(QString filename);
|
||||
|
||||
bool isServerlessMode() const { return !_serversEnabled; }
|
||||
bool isServerlessMode() const { return _serverlessDomain; }
|
||||
|
||||
void replaceDomainContent(const QString& url);
|
||||
|
||||
|
@ -394,7 +394,7 @@ public slots:
|
|||
const QString getPreferredCursor() const { return _preferredCursor.get(); }
|
||||
void setPreferredCursor(const QString& cursor);
|
||||
|
||||
void setServersEnabled(bool enableServers);
|
||||
void setServerlessDomain(bool serverlessDomain);
|
||||
void loadServerlessDomain(QUrl domainURL);
|
||||
|
||||
private slots:
|
||||
|
@ -429,7 +429,7 @@ private slots:
|
|||
|
||||
void setSessionUUID(const QUuid& sessionUUID) const;
|
||||
|
||||
void domainChanged(const QString& domainHostname);
|
||||
void domainURLChanged(QUrl domainURL);
|
||||
void updateWindowTitle() const;
|
||||
void nodeAdded(SharedNodePointer node) const;
|
||||
void nodeActivated(SharedNodePointer node);
|
||||
|
@ -480,7 +480,6 @@ private:
|
|||
bool importJSONFromURL(const QString& urlString);
|
||||
bool importSVOFromURL(const QString& urlString);
|
||||
bool importFromZIP(const QString& filePath);
|
||||
bool visitServerlessDomain(const QString& urlString);
|
||||
bool importImage(const QString& urlString);
|
||||
|
||||
bool nearbyEntitiesAreReadyForPhysics();
|
||||
|
@ -721,6 +720,6 @@ private:
|
|||
std::atomic<bool> _pendingIdleEvent { true };
|
||||
std::atomic<bool> _pendingRenderEvent { true };
|
||||
|
||||
bool _serversEnabled { true };
|
||||
bool _serverlessDomain { true };
|
||||
};
|
||||
#endif // hifi_Application_h
|
||||
|
|
|
@ -126,7 +126,7 @@ void WindowScriptingInterface::promptAsync(const QString& message, const QString
|
|||
}
|
||||
|
||||
void WindowScriptingInterface::disconnectedFromDomain() {
|
||||
emit domainChanged("", QUrl());
|
||||
emit domainChanged(QUrl());
|
||||
}
|
||||
|
||||
QString fixupPathForMac(const QString& directory) {
|
||||
|
|
|
@ -524,7 +524,7 @@ signals:
|
|||
* Triggered when you change the domain you're visiting. <strong>Warning:</strong> Is not emitted if you go to domain that
|
||||
* isn't running.
|
||||
* @function Window.domainChanged
|
||||
* @param {string} domain - The domain's IP address.
|
||||
* @param {string} domainURL - The domain's URL.
|
||||
* @returns {Signal}
|
||||
* @example <caption>Report when you change domains.</caption>
|
||||
* function onDomainChanged(domain) {
|
||||
|
@ -533,7 +533,7 @@ signals:
|
|||
*
|
||||
* Window.domainChanged.connect(onDomainChanged);
|
||||
*/
|
||||
void domainChanged(const QString& domain, const QUrl& serverlessDomainURL);
|
||||
void domainChanged(QUrl domainURL);
|
||||
|
||||
/**jsdoc
|
||||
* Triggered when you try to navigate to a *.json, *.svo, or *.svo.json URL in a Web browser within Interface.
|
||||
|
|
|
@ -2175,7 +2175,7 @@ QVector<EntityItemID> EntityTree::sendEntities(EntityEditPacketSender* packetSen
|
|||
localTree->recurseTreeWithOperator(&moveOperator);
|
||||
}
|
||||
|
||||
if (_serversEnabled) {
|
||||
if (!_serverlessDomain) {
|
||||
// send add-entity packets to the server
|
||||
i = map.begin();
|
||||
while (i != map.end()) {
|
||||
|
|
|
@ -283,8 +283,8 @@ public:
|
|||
|
||||
void setMyAvatar(std::shared_ptr<AvatarData> myAvatar) { _myAvatar = myAvatar; }
|
||||
|
||||
void setIsServerlessMode(bool value) { _serversEnabled = !value; }
|
||||
bool isServerlessMode() const { return !_serversEnabled; }
|
||||
void setIsServerlessMode(bool value) { _serverlessDomain = value; }
|
||||
bool isServerlessMode() const { return _serverlessDomain; }
|
||||
|
||||
static void setAddMaterialToEntityOperator(std::function<bool(const QUuid&, graphics::MaterialLayer, const std::string&)> addMaterialToEntityOperator) { _addMaterialToEntityOperator = addMaterialToEntityOperator; }
|
||||
static void setRemoveMaterialFromEntityOperator(std::function<bool(const QUuid&, graphics::MaterialPointer, const std::string&)> removeMaterialFromEntityOperator) { _removeMaterialFromEntityOperator = removeMaterialFromEntityOperator; }
|
||||
|
@ -416,7 +416,7 @@ private:
|
|||
static std::function<bool(const QUuid&, graphics::MaterialLayer, const std::string&)> _addMaterialToOverlayOperator;
|
||||
static std::function<bool(const QUuid&, graphics::MaterialPointer, const std::string&)> _removeMaterialFromOverlayOperator;
|
||||
|
||||
bool _serversEnabled { true };
|
||||
bool _serverlessDomain { false };
|
||||
};
|
||||
|
||||
#endif // hifi_EntityTree_h
|
||||
|
|
|
@ -41,12 +41,6 @@ const QString SETTINGS_CURRENT_ADDRESS_KEY = "address";
|
|||
|
||||
Setting::Handle<QUrl> currentAddressHandle(QStringList() << ADDRESS_MANAGER_SETTINGS_GROUP << "address", DEFAULT_HIFI_ADDRESS);
|
||||
|
||||
AddressManager::AddressManager() :
|
||||
_port(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString AddressManager::protocolVersion() {
|
||||
return protocolVersionsSignatureBase64();
|
||||
}
|
||||
|
@ -56,18 +50,7 @@ bool AddressManager::isConnected() {
|
|||
}
|
||||
|
||||
QUrl AddressManager::currentAddress(bool domainOnly) const {
|
||||
QUrl hifiURL;
|
||||
|
||||
if (!_serverlessDomainURL.isEmpty()) {
|
||||
hifiURL = _serverlessDomainURL;
|
||||
} else {
|
||||
hifiURL.setScheme(HIFI_URL_SCHEME);
|
||||
hifiURL.setHost(_host);
|
||||
|
||||
if (_port != 0 && _port != DEFAULT_DOMAIN_SERVER_PORT) {
|
||||
hifiURL.setPort(_port);
|
||||
}
|
||||
}
|
||||
QUrl hifiURL = _domainURL;
|
||||
|
||||
if (!domainOnly && hifiURL.scheme() == HIFI_URL_SCHEME) {
|
||||
hifiURL.setPath(currentPath());
|
||||
|
@ -219,7 +202,7 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
|
|||
|
||||
if (lookupUrl.scheme() == HIFI_URL_SCHEME) {
|
||||
|
||||
emit setServersEnabled(true);
|
||||
emit setServerlessDomain(false);
|
||||
|
||||
qCDebug(networking) << "Trying to go to URL" << lookupUrl.toString();
|
||||
|
||||
|
@ -303,8 +286,8 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
|
|||
} else if (lookupUrl.scheme() == "http" || lookupUrl.scheme() == "https" || lookupUrl.scheme() == "file") {
|
||||
_previousLookup.clear();
|
||||
QUrl domainUrl = PathUtils::expandToLocalDataAbsolutePath(lookupUrl);
|
||||
emit setServersEnabled(false);
|
||||
setDomainInfo(domainUrl, QString(), 0, trigger);
|
||||
emit setServerlessDomain(true);
|
||||
setDomainInfo(domainUrl, trigger);
|
||||
DependencyManager::get<NodeList>()->getDomainHandler().setIsConnected(true);
|
||||
emit lookupResultsFinished();
|
||||
return true;
|
||||
|
@ -417,7 +400,11 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const
|
|||
|
||||
qCDebug(networking) << "Possible domain change required to connect to" << domainHostname
|
||||
<< "on" << domainPort;
|
||||
emit possibleDomainChangeRequired(QUrl(), domainHostname, domainPort, domainID);
|
||||
QUrl domainURL;
|
||||
domainURL.setScheme(HIFI_URL_SCHEME);
|
||||
domainURL.setHost(domainHostname);
|
||||
domainURL.setPort(domainPort);
|
||||
emit possibleDomainChangeRequired(domainURL, domainID);
|
||||
} else {
|
||||
QString iceServerAddress = domainObject[DOMAIN_ICE_SERVER_ADDRESS_KEY].toString();
|
||||
|
||||
|
@ -454,15 +441,10 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const
|
|||
if (setHost(placeName, trigger)) {
|
||||
trigger = LookupTrigger::Internal;
|
||||
}
|
||||
|
||||
_placeName = placeName;
|
||||
} else {
|
||||
if (setHost(domainIDString, trigger)) {
|
||||
trigger = LookupTrigger::Internal;
|
||||
}
|
||||
|
||||
// this isn't a place, so clear the place name
|
||||
_placeName.clear();
|
||||
}
|
||||
|
||||
// check if we had a path to override the path returned
|
||||
|
@ -589,7 +571,11 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString, LookupTri
|
|||
}
|
||||
|
||||
emit lookupResultsFinished();
|
||||
hostChanged = setDomainInfo(QUrl(), domainIPString, domainPort, trigger);
|
||||
QUrl domainURL;
|
||||
domainURL.setScheme(HIFI_URL_SCHEME);
|
||||
domainURL.setHost(domainIPString);
|
||||
domainURL.setPort(domainPort);
|
||||
hostChanged = setDomainInfo(domainURL, trigger);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -606,7 +592,11 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString, LookupTri
|
|||
}
|
||||
|
||||
emit lookupResultsFinished();
|
||||
hostChanged = setDomainInfo(QUrl(), domainHostname, domainPort, trigger);
|
||||
QUrl domainURL;
|
||||
domainURL.setScheme(HIFI_URL_SCHEME);
|
||||
domainURL.setHost(domainHostname);
|
||||
domainURL.setPort(domainPort);
|
||||
hostChanged = setDomainInfo(domainURL, trigger);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -730,17 +720,19 @@ bool AddressManager::handleUsername(const QString& lookupString) {
|
|||
}
|
||||
|
||||
bool AddressManager::setHost(const QString& host, LookupTrigger trigger, quint16 port) {
|
||||
if (host != _host || port != _port) {
|
||||
if (host != _domainURL.host() || port != _domainURL.port()) {
|
||||
addCurrentAddressToHistory(trigger);
|
||||
|
||||
_port = port;
|
||||
bool emitHostChanged = host != _domainURL.host();
|
||||
_domainURL.setScheme(HIFI_URL_SCHEME);
|
||||
_domainURL.setHost(host);
|
||||
_domainURL.setPort(port);
|
||||
|
||||
// any host change should clear the shareable place name
|
||||
_shareablePlaceName.clear();
|
||||
_serverlessDomainURL = QUrl();
|
||||
|
||||
if (host != _host) {
|
||||
_host = host;
|
||||
emit hostChanged(_host);
|
||||
if (emitHostChanged) {
|
||||
emit hostChanged(host);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -749,26 +741,43 @@ bool AddressManager::setHost(const QString& host, LookupTrigger trigger, quint16
|
|||
return false;
|
||||
}
|
||||
|
||||
bool AddressManager::setDomainInfo(const QUrl& serverlessDomainURL,
|
||||
const QString& hostname, quint16 port, LookupTrigger trigger) {
|
||||
bool hostChanged = setHost(hostname, trigger, port);
|
||||
QString AddressManager::getHost() const {
|
||||
if (isPossiblePlaceName(_domainURL.host())) {
|
||||
return QString();
|
||||
}
|
||||
|
||||
return _domainURL.host();
|
||||
}
|
||||
|
||||
bool AddressManager::setDomainInfo(const QUrl& domainURL, LookupTrigger trigger) {
|
||||
const QString hostname = domainURL.host();
|
||||
quint16 port = domainURL.port();
|
||||
bool emitHostChanged { false };
|
||||
|
||||
if (domainURL.host() != _domainURL.host() || domainURL.port() != _domainURL.port()) {
|
||||
addCurrentAddressToHistory(trigger);
|
||||
emitHostChanged = true;
|
||||
}
|
||||
|
||||
_domainURL = domainURL;
|
||||
|
||||
// clear any current place information
|
||||
_rootPlaceID = QUuid();
|
||||
_placeName.clear();
|
||||
_serverlessDomainURL = serverlessDomainURL;
|
||||
|
||||
if (!serverlessDomainURL.isEmpty()) {
|
||||
qCDebug(networking) << "Possible domain change required to serverless domain: " << serverlessDomainURL.toString();
|
||||
} else {
|
||||
if (_domainURL.scheme() == HIFI_URL_SCHEME) {
|
||||
qCDebug(networking) << "Possible domain change required to connect to domain at" << hostname << "on" << port;
|
||||
} else {
|
||||
qCDebug(networking) << "Possible domain change required to serverless domain: " << domainURL.toString();
|
||||
}
|
||||
|
||||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::HandleAddress);
|
||||
|
||||
emit possibleDomainChangeRequired(serverlessDomainURL, hostname, port, QUuid());
|
||||
if (emitHostChanged) {
|
||||
emit hostChanged(domainURL.host());
|
||||
}
|
||||
emit possibleDomainChangeRequired(_domainURL, QUuid());
|
||||
|
||||
return hostChanged;
|
||||
return emitHostChanged;
|
||||
}
|
||||
|
||||
void AddressManager::goToUser(const QString& username, bool shouldMatchOrientation) {
|
||||
|
@ -857,7 +866,7 @@ void AddressManager::lookupShareableNameForDomainID(const QUuid& domainID) {
|
|||
// then use that for Steam join/invite or copiable address
|
||||
|
||||
// it only makes sense to lookup a shareable default name if we don't have a place name
|
||||
if (_placeName.isEmpty()) {
|
||||
if (getPlaceName().isEmpty()) {
|
||||
JSONCallbackParameters callbackParams;
|
||||
|
||||
// no error callback handling
|
||||
|
@ -909,3 +918,12 @@ void AddressManager::addCurrentAddressToHistory(LookupTrigger trigger) {
|
|||
}
|
||||
}
|
||||
|
||||
QString AddressManager::getPlaceName() const {
|
||||
if (!_shareablePlaceName.isEmpty()) {
|
||||
return _shareablePlaceName;
|
||||
}
|
||||
if (isPossiblePlaceName(_domainURL.host())) {
|
||||
return _domainURL.host();
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
|
||||
#include "AccountManager.h"
|
||||
|
||||
const QString HIFI_URL_SCHEME = "hifi";
|
||||
|
||||
extern const QString DEFAULT_HIFI_ADDRESS;
|
||||
|
||||
const QString SANDBOX_HIFI_ADDRESS = "hifi://localhost";
|
||||
|
@ -166,10 +164,10 @@ public:
|
|||
QString currentFacingPath() const;
|
||||
|
||||
const QUuid& getRootPlaceID() const { return _rootPlaceID; }
|
||||
const QString& getPlaceName() const { return _shareablePlaceName.isEmpty() ? _placeName : _shareablePlaceName; }
|
||||
QString getPlaceName() const;
|
||||
QString getDomainID() const;
|
||||
|
||||
const QString& getHost() const { return _host; }
|
||||
QString getHost() const;
|
||||
|
||||
void setPositionGetter(PositionGetter positionGetter) { _positionGetter = positionGetter; }
|
||||
void setOrientationGetter(OrientationGetter orientationGetter) { _orientationGetter = orientationGetter; }
|
||||
|
@ -179,7 +177,7 @@ public:
|
|||
const QStack<QUrl>& getBackStack() const { return _backStack; }
|
||||
const QStack<QUrl>& getForwardStack() const { return _forwardStack; }
|
||||
|
||||
QUrl getServerlessDomainURL() { return _serverlessDomainURL; }
|
||||
QUrl getDomainURL() { return _domainURL; }
|
||||
|
||||
public slots:
|
||||
/**jsdoc
|
||||
|
@ -313,15 +311,12 @@ signals:
|
|||
/**jsdoc
|
||||
* Triggered when a request is made to go to an IP address.
|
||||
* @function location.possibleDomainChangeRequired
|
||||
* @param {string} serverlessDomainURL - URL for a file-based domain
|
||||
* @param {string} hostName - The name of the domain to go do.
|
||||
* @param {number} port - The integer number of the network port to connect to.
|
||||
* @param {Url} domainURL - URL for domain
|
||||
* @param {Uuid} domainID - The UUID of the domain to go to.
|
||||
* @returns {Signal}
|
||||
*/
|
||||
// No example because this function isn't typically used in scripts.
|
||||
void possibleDomainChangeRequired(const QUrl& serverlessDomainURL,
|
||||
const QString& newHostname, quint16 newPort, const QUuid& domainID);
|
||||
void possibleDomainChangeRequired(QUrl domainURL, QUuid domainID);
|
||||
|
||||
/**jsdoc
|
||||
* Triggered when a request is made to go to a named domain or user.
|
||||
|
@ -420,11 +415,9 @@ signals:
|
|||
*/
|
||||
void goForwardPossible(bool isPossible);
|
||||
|
||||
void setServersEnabled(bool serversEnabled);
|
||||
void setServerlessDomain(bool serverlessDomain);
|
||||
void loadServerlessDomain(QUrl domainURL);
|
||||
|
||||
protected:
|
||||
AddressManager();
|
||||
private slots:
|
||||
void handleAPIResponse(QNetworkReply& requestReply);
|
||||
void handleAPIError(QNetworkReply& errorReply);
|
||||
|
@ -436,7 +429,7 @@ private:
|
|||
|
||||
// Set host and port, and return `true` if it was changed.
|
||||
bool setHost(const QString& host, LookupTrigger trigger, quint16 port = 0);
|
||||
bool setDomainInfo(const QUrl& serverlessDomainURL, const QString& hostname, quint16 port, LookupTrigger trigger);
|
||||
bool setDomainInfo(const QUrl& domainURL, LookupTrigger trigger);
|
||||
|
||||
const JSONCallbackParameters& apiCallbackParameters();
|
||||
|
||||
|
@ -454,10 +447,8 @@ private:
|
|||
|
||||
void addCurrentAddressToHistory(LookupTrigger trigger);
|
||||
|
||||
QString _host;
|
||||
quint16 _port;
|
||||
QString _placeName;
|
||||
QUrl _serverlessDomainURL; // for file-based domains
|
||||
QUrl _domainURL;
|
||||
|
||||
QUuid _rootPlaceID;
|
||||
PositionGetter _positionGetter;
|
||||
OrientationGetter _orientationGetter;
|
||||
|
|
|
@ -115,9 +115,8 @@ void DomainHandler::hardReset() {
|
|||
qCDebug(networking) << "Hard reset in NodeList DomainHandler.";
|
||||
_pendingDomainID = QUuid();
|
||||
_iceServerSockAddr = HifiSockAddr();
|
||||
_hostname = QString();
|
||||
_sockAddr.clear();
|
||||
_serverlessDomainURL = QUrl();
|
||||
_domainURL = QUrl();
|
||||
|
||||
_domainConnectionRefusals.clear();
|
||||
|
||||
|
@ -140,8 +139,7 @@ void DomainHandler::setSockAddr(const HifiSockAddr& sockAddr, const QString& hos
|
|||
}
|
||||
|
||||
// some callers may pass a hostname, this is not to be used for lookup but for DTLS certificate verification
|
||||
_hostname = hostname;
|
||||
_serverlessDomainURL = QUrl();
|
||||
_domainURL = QUrl();
|
||||
}
|
||||
|
||||
void DomainHandler::setUUID(const QUuid& uuid) {
|
||||
|
@ -151,42 +149,37 @@ void DomainHandler::setUUID(const QUuid& uuid) {
|
|||
}
|
||||
}
|
||||
|
||||
void DomainHandler::setSocketAndID(const QUrl& serverlessDomainURL,
|
||||
const QString& hostname, quint16 port, const QUuid& domainID) {
|
||||
|
||||
void DomainHandler::setURLAndID(QUrl domainURL, QUuid domainID) {
|
||||
_pendingDomainID = domainID;
|
||||
|
||||
if (serverlessDomainURL != _serverlessDomainURL || hostname != _hostname || _sockAddr.getPort() != port) {
|
||||
if (_domainURL != domainURL || _sockAddr.getPort() != domainURL.port()) {
|
||||
// re-set the domain info so that auth information is reloaded
|
||||
hardReset();
|
||||
|
||||
if (serverlessDomainURL != _serverlessDomainURL) {
|
||||
_serverlessDomainURL = serverlessDomainURL;
|
||||
if (_serverlessDomainURL != QUrl()) {
|
||||
setIsConnected(true);
|
||||
}
|
||||
emit serverlessDomainChanged(_serverlessDomainURL);
|
||||
}
|
||||
QString hostname = domainURL.host();
|
||||
quint16 port = domainURL.port();
|
||||
|
||||
if (hostname != _hostname) {
|
||||
// set the new hostname
|
||||
_hostname = hostname;
|
||||
_domainURL = domainURL;
|
||||
|
||||
qCDebug(networking) << "Updated domain hostname to" << _hostname;
|
||||
if (domainURL.scheme() != HIFI_URL_SCHEME) {
|
||||
setIsConnected(true);
|
||||
} else if (hostname != _domainURL.host()) {
|
||||
qCDebug(networking) << "Updated domain hostname to" << hostname;
|
||||
|
||||
if (!_hostname.isEmpty()) {
|
||||
if (!hostname.isEmpty()) {
|
||||
// re-set the sock addr to null and fire off a lookup of the IP address for this domain-server's hostname
|
||||
qCDebug(networking, "Looking up DS hostname %s.", _hostname.toLocal8Bit().constData());
|
||||
QHostInfo::lookupHost(_hostname, this, SLOT(completedHostnameLookup(const QHostInfo&)));
|
||||
qCDebug(networking, "Looking up DS hostname %s.", hostname.toLocal8Bit().constData());
|
||||
QHostInfo::lookupHost(hostname, this, SLOT(completedHostnameLookup(const QHostInfo&)));
|
||||
|
||||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(
|
||||
LimitedNodeList::ConnectionStep::SetDomainHostname);
|
||||
|
||||
UserActivityLogger::getInstance().changedDomain(_hostname);
|
||||
UserActivityLogger::getInstance().changedDomain(hostname);
|
||||
}
|
||||
emit hostnameChanged(_hostname);
|
||||
}
|
||||
|
||||
emit domainURLChanged(_domainURL);
|
||||
|
||||
if (_sockAddr.getPort() != port) {
|
||||
qCDebug(networking) << "Updated domain port to" << port;
|
||||
}
|
||||
|
@ -198,9 +191,10 @@ void DomainHandler::setSocketAndID(const QUrl& serverlessDomainURL,
|
|||
|
||||
void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname, const QUuid& id) {
|
||||
|
||||
if (_serverlessDomainURL != QUrl()) {
|
||||
_serverlessDomainURL = QUrl();
|
||||
emit serverlessDomainChanged(QUrl());
|
||||
if (isServerless()) {
|
||||
// if we were connected to a serverless domain, clear the octree, etc
|
||||
_domainURL = QUrl();
|
||||
emit domainURLChanged(_domainURL);
|
||||
}
|
||||
|
||||
if (_iceServerSockAddr.getAddress().toString() != iceServerHostname || id != _pendingDomainID) {
|
||||
|
@ -235,16 +229,16 @@ void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname,
|
|||
void DomainHandler::activateICELocalSocket() {
|
||||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket);
|
||||
_sockAddr = _icePeer.getLocalSocket();
|
||||
_hostname = _sockAddr.getAddress().toString();
|
||||
_serverlessDomainURL = QUrl();
|
||||
_domainURL.setScheme(HIFI_URL_SCHEME);
|
||||
_domainURL.setHost(_sockAddr.getAddress().toString());
|
||||
emit completedSocketDiscovery();
|
||||
}
|
||||
|
||||
void DomainHandler::activateICEPublicSocket() {
|
||||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket);
|
||||
_sockAddr = _icePeer.getPublicSocket();
|
||||
_hostname = _sockAddr.getAddress().toString();
|
||||
_serverlessDomainURL = QUrl();
|
||||
_domainURL.setScheme(HIFI_URL_SCHEME);
|
||||
_domainURL.setHost(_sockAddr.getAddress().toString());
|
||||
emit completedSocketDiscovery();
|
||||
}
|
||||
|
||||
|
@ -255,7 +249,7 @@ void DomainHandler::completedHostnameLookup(const QHostInfo& hostInfo) {
|
|||
|
||||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket);
|
||||
|
||||
qCDebug(networking, "DS at %s is at %s", _hostname.toLocal8Bit().constData(),
|
||||
qCDebug(networking, "DS at %s is at %s", _domainURL.host().toLocal8Bit().constData(),
|
||||
_sockAddr.getAddress().toString().toLocal8Bit().constData());
|
||||
|
||||
emit completedSocketDiscovery();
|
||||
|
@ -282,9 +276,9 @@ void DomainHandler::setIsConnected(bool isConnected) {
|
|||
_isConnected = isConnected;
|
||||
|
||||
if (_isConnected) {
|
||||
emit connectedToDomain(_hostname, _serverlessDomainURL);
|
||||
emit connectedToDomain(_domainURL);
|
||||
|
||||
if (!_hostname.isEmpty()) {
|
||||
if (_domainURL.scheme() == HIFI_URL_SCHEME && !_domainURL.host().isEmpty()) {
|
||||
// we've connected to new domain - time to ask it for global settings
|
||||
requestDomainSettings();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "NLPacketList.h"
|
||||
#include "Node.h"
|
||||
#include "ReceivedMessage.h"
|
||||
#include "NetworkingConstants.h"
|
||||
|
||||
const unsigned short DEFAULT_DOMAIN_SERVER_PORT = 40102;
|
||||
const unsigned short DEFAULT_DOMAIN_SERVER_DTLS_PORT = 40103;
|
||||
|
@ -37,14 +38,14 @@ class DomainHandler : public QObject {
|
|||
Q_OBJECT
|
||||
public:
|
||||
DomainHandler(QObject* parent = 0);
|
||||
|
||||
|
||||
void disconnect();
|
||||
void clearSettings();
|
||||
|
||||
const QUuid& getUUID() const { return _uuid; }
|
||||
void setUUID(const QUuid& uuid);
|
||||
|
||||
const QString& getHostname() const { return _hostname; }
|
||||
QString getHostname() const { return _domainURL.host(); }
|
||||
|
||||
const QHostAddress& getIP() const { return _sockAddr.getAddress(); }
|
||||
void setIPToLocalhost() { _sockAddr.setAddress(QHostAddress(QHostAddress::LocalHost)); }
|
||||
|
@ -57,7 +58,7 @@ public:
|
|||
|
||||
const QUuid& getConnectionToken() const { return _connectionToken; }
|
||||
void setConnectionToken(const QUuid& connectionToken) { _connectionToken = connectionToken; }
|
||||
|
||||
|
||||
const QUuid& getAssignmentUUID() const { return _assignmentUUID; }
|
||||
void setAssignmentUUID(const QUuid& assignmentUUID) { _assignmentUUID = assignmentUUID; }
|
||||
|
||||
|
@ -73,12 +74,12 @@ public:
|
|||
|
||||
bool isConnected() const { return _isConnected; }
|
||||
void setIsConnected(bool isConnected);
|
||||
bool isServerless() const { return _serverlessDomainURL != QUrl(); }
|
||||
bool isServerless() const { return _domainURL.scheme() != HIFI_URL_SCHEME; }
|
||||
|
||||
bool hasSettings() const { return !_settingsObject.isEmpty(); }
|
||||
void requestDomainSettings();
|
||||
const QJsonObject& getSettingsObject() const { return _settingsObject; }
|
||||
|
||||
|
||||
void setPendingPath(const QString& pendingPath) { _pendingPath = pendingPath; }
|
||||
const QString& getPendingPath() { return _pendingPath; }
|
||||
void clearPendingPath() { _pendingPath.clear(); }
|
||||
|
@ -140,8 +141,7 @@ public:
|
|||
};
|
||||
|
||||
public slots:
|
||||
void setSocketAndID(const QUrl& serverlessDomainURL,
|
||||
const QString& hostname, quint16 port = DEFAULT_DOMAIN_SERVER_PORT, const QUuid& id = QUuid());
|
||||
void setURLAndID(QUrl domainURL, QUuid id);
|
||||
void setIceServerHostnameAndID(const QString& iceServerHostname, const QUuid& id);
|
||||
|
||||
void processSettingsPacketList(QSharedPointer<ReceivedMessage> packetList);
|
||||
|
@ -155,15 +155,14 @@ private slots:
|
|||
void completedIceServerHostnameLookup();
|
||||
|
||||
signals:
|
||||
void hostnameChanged(const QString& hostname);
|
||||
void serverlessDomainChanged(QUrl serverlessDomainURL);
|
||||
void domainURLChanged(QUrl domainURL);
|
||||
|
||||
// NOTE: the emission of completedSocketDiscovery does not mean a connection to DS is established
|
||||
// It means that, either from DNS lookup or ICE, we think we have a socket we can talk to DS on
|
||||
void completedSocketDiscovery();
|
||||
|
||||
void resetting();
|
||||
void connectedToDomain(const QString& hostname, const QUrl& serverlessDomainURL);
|
||||
void connectedToDomain(QUrl domainURL);
|
||||
void disconnectedFromDomain();
|
||||
|
||||
void iceSocketAndIDReceived();
|
||||
|
@ -182,8 +181,7 @@ private:
|
|||
void hardReset();
|
||||
|
||||
QUuid _uuid;
|
||||
QUrl _serverlessDomainURL;
|
||||
QString _hostname;
|
||||
QUrl _domainURL;
|
||||
HifiSockAddr _sockAddr;
|
||||
QUuid _assignmentUUID;
|
||||
QUuid _connectionToken;
|
||||
|
|
35
libraries/networking/src/NetworkingConstants.cpp
Normal file
35
libraries/networking/src/NetworkingConstants.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
//
|
||||
// NetworkingConstants.cpp
|
||||
// libraries/networking/src
|
||||
//
|
||||
// Created by Seth Alves on 2018-2-28.
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
#include "NetworkingConstants.h"
|
||||
|
||||
namespace NetworkingConstants {
|
||||
QUrl METAVERSE_SERVER_URL_STABLE() {
|
||||
return QUrl("https://metaverse.highfidelity.com");
|
||||
}
|
||||
|
||||
QUrl METAVERSE_SERVER_URL_STAGING() {
|
||||
return QUrl("https://staging.highfidelity.com");
|
||||
}
|
||||
|
||||
// You can change the return of this function if you want to use a custom metaverse URL at compile time
|
||||
// or you can pass a custom URL via the env variable
|
||||
QUrl METAVERSE_SERVER_URL() {
|
||||
static const QString HIFI_METAVERSE_URL_ENV = "HIFI_METAVERSE_URL";
|
||||
static const QUrl serverURL = QProcessEnvironment::systemEnvironment().contains(HIFI_METAVERSE_URL_ENV)
|
||||
? QUrl(QProcessEnvironment::systemEnvironment().value(HIFI_METAVERSE_URL_ENV))
|
||||
: METAVERSE_SERVER_URL_STABLE();
|
||||
return serverURL;
|
||||
};
|
||||
}
|
|
@ -25,18 +25,11 @@ namespace NetworkingConstants {
|
|||
// if you manually generate a personal access token for the domains scope
|
||||
// at https://staging.highfidelity.com/user/tokens/new?for_domain_server=true
|
||||
|
||||
const QUrl METAVERSE_SERVER_URL_STABLE("https://metaverse.highfidelity.com");
|
||||
const QUrl METAVERSE_SERVER_URL_STAGING("https://staging.highfidelity.com");
|
||||
|
||||
// You can change the return of this function if you want to use a custom metaverse URL at compile time
|
||||
// or you can pass a custom URL via the env variable
|
||||
static const QUrl METAVERSE_SERVER_URL() {
|
||||
static const QString HIFI_METAVERSE_URL_ENV = "HIFI_METAVERSE_URL";
|
||||
static const QUrl serverURL = QProcessEnvironment::systemEnvironment().contains(HIFI_METAVERSE_URL_ENV)
|
||||
? QUrl(QProcessEnvironment::systemEnvironment().value(HIFI_METAVERSE_URL_ENV))
|
||||
: METAVERSE_SERVER_URL_STABLE;
|
||||
return serverURL;
|
||||
};
|
||||
QUrl METAVERSE_SERVER_URL_STABLE();
|
||||
QUrl METAVERSE_SERVER_URL_STAGING();
|
||||
QUrl METAVERSE_SERVER_URL();
|
||||
}
|
||||
|
||||
const QString HIFI_URL_SCHEME = "hifi";
|
||||
|
||||
#endif // hifi_NetworkingConstants_h
|
||||
|
|
|
@ -55,7 +55,7 @@ NodeList::NodeList(char newOwnerType, int socketListenPort, int dtlsListenPort)
|
|||
|
||||
// handle domain change signals from AddressManager
|
||||
connect(addressManager.data(), &AddressManager::possibleDomainChangeRequired,
|
||||
&_domainHandler, &DomainHandler::setSocketAndID);
|
||||
&_domainHandler, &DomainHandler::setURLAndID);
|
||||
|
||||
connect(addressManager.data(), &AddressManager::possibleDomainChangeRequiredViaICEForID,
|
||||
&_domainHandler, &DomainHandler::setIceServerHostnameAndID);
|
||||
|
@ -91,7 +91,7 @@ NodeList::NodeList(char newOwnerType, int socketListenPort, int dtlsListenPort)
|
|||
connect(accountManager.data(), &AccountManager::newKeypair, this, &NodeList::sendDomainServerCheckIn);
|
||||
|
||||
// clear out NodeList when login is finished
|
||||
connect(accountManager.data(), SIGNAL(loginComplete()) , this, SLOT(reset()));
|
||||
connect(accountManager.data(), SIGNAL(loginComplete(const QUrl&)) , this, SLOT(reset()));
|
||||
|
||||
// clear our NodeList when logout is requested
|
||||
connect(accountManager.data(), SIGNAL(logoutComplete()) , this, SLOT(reset()));
|
||||
|
@ -106,7 +106,7 @@ NodeList::NodeList(char newOwnerType, int socketListenPort, int dtlsListenPort)
|
|||
// setup our timer to send keepalive pings (it's started and stopped on domain connect/disconnect)
|
||||
_keepAlivePingTimer.setInterval(KEEPALIVE_PING_INTERVAL_MS); // 1s, Qt::CoarseTimer acceptable
|
||||
connect(&_keepAlivePingTimer, &QTimer::timeout, this, &NodeList::sendKeepAlivePings);
|
||||
connect(&_domainHandler, SIGNAL(connectedToDomain(QString)), &_keepAlivePingTimer, SLOT(start()));
|
||||
connect(&_domainHandler, SIGNAL(connectedToDomain(QUrl)), &_keepAlivePingTimer, SLOT(start()));
|
||||
connect(&_domainHandler, &DomainHandler::disconnectedFromDomain, &_keepAlivePingTimer, &QTimer::stop);
|
||||
|
||||
// set our sockAddrBelongsToDomainOrNode method as the connection creation filter for the udt::Socket
|
||||
|
|
|
@ -119,7 +119,7 @@ ACClientApp::ACClientApp(int argc, char* argv[]) :
|
|||
nodeList->startThread();
|
||||
|
||||
const DomainHandler& domainHandler = nodeList->getDomainHandler();
|
||||
connect(&domainHandler, SIGNAL(hostnameChanged(const QString&)), SLOT(domainChanged(const QString&)));
|
||||
connect(&domainHandler, SIGNAL(domainURLChanged(QUrl)), SLOT(domainChanged(QUrl)));
|
||||
connect(&domainHandler, &DomainHandler::domainConnectionRefused, this, &ACClientApp::domainConnectionRefused);
|
||||
|
||||
connect(nodeList.data(), &NodeList::nodeAdded, this, &ACClientApp::nodeAdded);
|
||||
|
@ -169,7 +169,7 @@ void ACClientApp::domainConnectionRefused(const QString& reasonMessage, int reas
|
|||
qDebug() << "domainConnectionRefused";
|
||||
}
|
||||
|
||||
void ACClientApp::domainChanged(const QString& domainHostname) {
|
||||
void ACClientApp::domainChanged(QUrl domainURL) {
|
||||
if (_verbose) {
|
||||
qDebug() << "domainChanged";
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
|
||||
private slots:
|
||||
void domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo);
|
||||
void domainChanged(const QString& domainHostname);
|
||||
void domainChanged(QUrl domainURL);
|
||||
void nodeAdded(SharedNodePointer node);
|
||||
void nodeActivated(SharedNodePointer node);
|
||||
void nodeKilled(SharedNodePointer node);
|
||||
|
|
|
@ -158,7 +158,7 @@ ATPClientApp::ATPClientApp(int argc, char* argv[]) :
|
|||
nodeList->startThread();
|
||||
|
||||
const DomainHandler& domainHandler = nodeList->getDomainHandler();
|
||||
connect(&domainHandler, SIGNAL(hostnameChanged(const QString&)), SLOT(domainChanged(const QString&)));
|
||||
connect(&domainHandler, SIGNAL(domainURLChanged(QUrl)), SLOT(domainChanged(QUrl)));
|
||||
connect(&domainHandler, &DomainHandler::domainConnectionRefused, this, &ATPClientApp::domainConnectionRefused);
|
||||
|
||||
connect(nodeList.data(), &NodeList::nodeAdded, this, &ATPClientApp::nodeAdded);
|
||||
|
@ -227,7 +227,7 @@ void ATPClientApp::domainConnectionRefused(const QString& reasonMessage, int rea
|
|||
}
|
||||
}
|
||||
|
||||
void ATPClientApp::domainChanged(const QString& domainHostname) {
|
||||
void ATPClientApp::domainChanged(QUrl domainURL) {
|
||||
if (_verbose) {
|
||||
qDebug() << "domainChanged";
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
|
||||
private slots:
|
||||
void domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo);
|
||||
void domainChanged(const QString& domainHostname);
|
||||
void domainChanged(QUrl domainURL);
|
||||
void nodeAdded(SharedNodePointer node);
|
||||
void nodeActivated(SharedNodePointer node);
|
||||
void nodeKilled(SharedNodePointer node);
|
||||
|
|
Loading…
Reference in a new issue