mirror of
https://github.com/overte-org/overte.git
synced 2025-08-11 00:53:17 +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 JPG_EXTENSION = ".jpg";
|
||||||
static const QString PNG_EXTENSION = ".png";
|
static const QString PNG_EXTENSION = ".png";
|
||||||
static const QString SVO_EXTENSION = ".svo";
|
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 SVO_JSON_EXTENSION = ".svo.json";
|
||||||
static const QString JSON_GZ_EXTENSION = ".json.gz";
|
static const QString JSON_GZ_EXTENSION = ".json.gz";
|
||||||
static const QString JSON_EXTENSION = ".json";
|
static const QString JSON_EXTENSION = ".json";
|
||||||
|
@ -382,8 +380,6 @@ const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensi
|
||||||
{ SVO_EXTENSION, &Application::importSVOFromURL },
|
{ SVO_EXTENSION, &Application::importSVOFromURL },
|
||||||
{ SVO_JSON_EXTENSION, &Application::importSVOFromURL },
|
{ SVO_JSON_EXTENSION, &Application::importSVOFromURL },
|
||||||
{ AVA_JSON_EXTENSION, &Application::askToWearAvatarAttachmentUrl },
|
{ AVA_JSON_EXTENSION, &Application::askToWearAvatarAttachmentUrl },
|
||||||
{ SERVERLESS_DOMAIN_EXTENSION, &Application::visitServerlessDomain },
|
|
||||||
{ SERVERLESS_DOMAIN_GZ_EXTENSION, &Application::visitServerlessDomain },
|
|
||||||
{ JSON_EXTENSION, &Application::importJSONFromURL },
|
{ JSON_EXTENSION, &Application::importJSONFromURL },
|
||||||
{ JS_EXTENSION, &Application::askToLoadScript },
|
{ JS_EXTENSION, &Application::askToLoadScript },
|
||||||
{ FST_EXTENSION, &Application::askToSetAvatarUrl },
|
{ FST_EXTENSION, &Application::askToSetAvatarUrl },
|
||||||
|
@ -1112,10 +1108,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
|
|
||||||
const DomainHandler& domainHandler = nodeList->getDomainHandler();
|
const DomainHandler& domainHandler = nodeList->getDomainHandler();
|
||||||
|
|
||||||
connect(&domainHandler, SIGNAL(hostnameChanged(const QString&)), SLOT(domainChanged(const QString&)));
|
connect(&domainHandler, SIGNAL(domainURLChanged(QUrl)), SLOT(domainURLChanged(QUrl)));
|
||||||
connect(&domainHandler, SIGNAL(serverlessDomainChanged(QUrl)), SLOT(loadServerlessDomain(QUrl)));
|
|
||||||
connect(&domainHandler, SIGNAL(resetting()), SLOT(resettingDomain()));
|
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, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle()));
|
||||||
connect(&domainHandler, &DomainHandler::disconnectedFromDomain, this, &Application::clearDomainAvatars);
|
connect(&domainHandler, &DomainHandler::disconnectedFromDomain, this, &Application::clearDomainAvatars);
|
||||||
connect(&domainHandler, &DomainHandler::disconnectedFromDomain, this, [this]() {
|
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(addressManager.data(), &AddressManager::hostChanged, this, &Application::updateWindowTitle);
|
||||||
connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress);
|
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, &Application::updateThreadPoolCount);
|
||||||
connect(this, &Application::activeDisplayPluginChanged, this, [](){
|
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(&_addAssetToWorldErrorTimer, &QTimer::timeout, this, &Application::addAssetToWorldErrorTimeout);
|
||||||
|
|
||||||
connect(this, &QCoreApplication::aboutToQuit, this, &Application::addAssetToWorldMessageClose);
|
connect(this, &QCoreApplication::aboutToQuit, this, &Application::addAssetToWorldMessageClose);
|
||||||
connect(&domainHandler, &DomainHandler::hostnameChanged, this, &Application::addAssetToWorldMessageClose);
|
connect(&domainHandler, &DomainHandler::domainURLChanged, this, &Application::addAssetToWorldMessageClose);
|
||||||
|
|
||||||
updateSystemTabletMode();
|
updateSystemTabletMode();
|
||||||
|
|
||||||
|
@ -3104,18 +3099,13 @@ bool Application::importFromZIP(const QString& filePath) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setServersEnabled(bool serversEnabled) {
|
void Application::setServerlessDomain(bool serverlessDomain) {
|
||||||
if (_serversEnabled != serversEnabled) {
|
if (_serverlessDomain != serverlessDomain) {
|
||||||
_serversEnabled = serversEnabled;
|
_serverlessDomain = serverlessDomain;
|
||||||
getEntities()->getTree()->setIsServerlessMode(!_serversEnabled);
|
getEntities()->getTree()->setIsServerlessMode(_serverlessDomain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::visitServerlessDomain(const QString& urlString) {
|
|
||||||
DependencyManager::get<AddressManager>()->handleLookupString(urlString);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::loadServerlessDomain(QUrl domainURL) {
|
void Application::loadServerlessDomain(QUrl domainURL) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "loadServerlessDomain", Q_ARG(QUrl, domainURL));
|
QMetaObject::invokeMethod(this, "loadServerlessDomain", Q_ARG(QUrl, domainURL));
|
||||||
|
@ -5798,7 +5788,7 @@ void Application::updateWindowTitle() const {
|
||||||
|
|
||||||
QString currentPlaceName;
|
QString currentPlaceName;
|
||||||
if (isServerlessMode()) {
|
if (isServerlessMode()) {
|
||||||
currentPlaceName = "serverless: " + DependencyManager::get<AddressManager>()->getServerlessDomainURL().toString();
|
currentPlaceName = "serverless: " + DependencyManager::get<AddressManager>()->getDomainURL().toString();
|
||||||
} else {
|
} else {
|
||||||
currentPlaceName = DependencyManager::get<AddressManager>()->getHost();
|
currentPlaceName = DependencyManager::get<AddressManager>()->getHost();
|
||||||
if (currentPlaceName.isEmpty()) {
|
if (currentPlaceName.isEmpty()) {
|
||||||
|
@ -5816,7 +5806,7 @@ void Application::updateWindowTitle() const {
|
||||||
_window->setWindowTitle(title);
|
_window->setWindowTitle(title);
|
||||||
|
|
||||||
// updateTitleWindow gets called whenever there's a change regarding the domain, so rather
|
// 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", "");
|
DependencyManager::get< MessagesClient >()->sendLocalMessage("Toolbar-DomainChanged", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5855,11 +5845,14 @@ void Application::clearDomainAvatars() {
|
||||||
DependencyManager::get<AvatarManager>()->clearOtherAvatars();
|
DependencyManager::get<AvatarManager>()->clearOtherAvatars();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::domainChanged(const QString& domainHostname) {
|
void Application::domainURLChanged(QUrl domainURL) {
|
||||||
clearDomainOctreeDetails();
|
clearDomainOctreeDetails();
|
||||||
updateWindowTitle();
|
updateWindowTitle();
|
||||||
// disable physics until we have enough information about our new location to not cause craziness.
|
// disable physics until we have enough information about our new location to not cause craziness.
|
||||||
resetPhysicsReadyInformation();
|
resetPhysicsReadyInformation();
|
||||||
|
if (domainURL.scheme() != HIFI_URL_SCHEME) {
|
||||||
|
loadServerlessDomain(domainURL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -285,7 +285,7 @@ public:
|
||||||
bool getSaveAvatarOverrideUrl() { return _saveAvatarOverrideUrl; }
|
bool getSaveAvatarOverrideUrl() { return _saveAvatarOverrideUrl; }
|
||||||
void saveNextPhysicsStats(QString filename);
|
void saveNextPhysicsStats(QString filename);
|
||||||
|
|
||||||
bool isServerlessMode() const { return !_serversEnabled; }
|
bool isServerlessMode() const { return _serverlessDomain; }
|
||||||
|
|
||||||
void replaceDomainContent(const QString& url);
|
void replaceDomainContent(const QString& url);
|
||||||
|
|
||||||
|
@ -394,7 +394,7 @@ public slots:
|
||||||
const QString getPreferredCursor() const { return _preferredCursor.get(); }
|
const QString getPreferredCursor() const { return _preferredCursor.get(); }
|
||||||
void setPreferredCursor(const QString& cursor);
|
void setPreferredCursor(const QString& cursor);
|
||||||
|
|
||||||
void setServersEnabled(bool enableServers);
|
void setServerlessDomain(bool serverlessDomain);
|
||||||
void loadServerlessDomain(QUrl domainURL);
|
void loadServerlessDomain(QUrl domainURL);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -429,7 +429,7 @@ private slots:
|
||||||
|
|
||||||
void setSessionUUID(const QUuid& sessionUUID) const;
|
void setSessionUUID(const QUuid& sessionUUID) const;
|
||||||
|
|
||||||
void domainChanged(const QString& domainHostname);
|
void domainURLChanged(QUrl domainURL);
|
||||||
void updateWindowTitle() const;
|
void updateWindowTitle() const;
|
||||||
void nodeAdded(SharedNodePointer node) const;
|
void nodeAdded(SharedNodePointer node) const;
|
||||||
void nodeActivated(SharedNodePointer node);
|
void nodeActivated(SharedNodePointer node);
|
||||||
|
@ -480,7 +480,6 @@ private:
|
||||||
bool importJSONFromURL(const QString& urlString);
|
bool importJSONFromURL(const QString& urlString);
|
||||||
bool importSVOFromURL(const QString& urlString);
|
bool importSVOFromURL(const QString& urlString);
|
||||||
bool importFromZIP(const QString& filePath);
|
bool importFromZIP(const QString& filePath);
|
||||||
bool visitServerlessDomain(const QString& urlString);
|
|
||||||
bool importImage(const QString& urlString);
|
bool importImage(const QString& urlString);
|
||||||
|
|
||||||
bool nearbyEntitiesAreReadyForPhysics();
|
bool nearbyEntitiesAreReadyForPhysics();
|
||||||
|
@ -721,6 +720,6 @@ private:
|
||||||
std::atomic<bool> _pendingIdleEvent { true };
|
std::atomic<bool> _pendingIdleEvent { true };
|
||||||
std::atomic<bool> _pendingRenderEvent { true };
|
std::atomic<bool> _pendingRenderEvent { true };
|
||||||
|
|
||||||
bool _serversEnabled { true };
|
bool _serverlessDomain { true };
|
||||||
};
|
};
|
||||||
#endif // hifi_Application_h
|
#endif // hifi_Application_h
|
||||||
|
|
|
@ -126,7 +126,7 @@ void WindowScriptingInterface::promptAsync(const QString& message, const QString
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowScriptingInterface::disconnectedFromDomain() {
|
void WindowScriptingInterface::disconnectedFromDomain() {
|
||||||
emit domainChanged("", QUrl());
|
emit domainChanged(QUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString fixupPathForMac(const QString& directory) {
|
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
|
* Triggered when you change the domain you're visiting. <strong>Warning:</strong> Is not emitted if you go to domain that
|
||||||
* isn't running.
|
* isn't running.
|
||||||
* @function Window.domainChanged
|
* @function Window.domainChanged
|
||||||
* @param {string} domain - The domain's IP address.
|
* @param {string} domainURL - The domain's URL.
|
||||||
* @returns {Signal}
|
* @returns {Signal}
|
||||||
* @example <caption>Report when you change domains.</caption>
|
* @example <caption>Report when you change domains.</caption>
|
||||||
* function onDomainChanged(domain) {
|
* function onDomainChanged(domain) {
|
||||||
|
@ -533,7 +533,7 @@ signals:
|
||||||
*
|
*
|
||||||
* Window.domainChanged.connect(onDomainChanged);
|
* Window.domainChanged.connect(onDomainChanged);
|
||||||
*/
|
*/
|
||||||
void domainChanged(const QString& domain, const QUrl& serverlessDomainURL);
|
void domainChanged(QUrl domainURL);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Triggered when you try to navigate to a *.json, *.svo, or *.svo.json URL in a Web browser within Interface.
|
* 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);
|
localTree->recurseTreeWithOperator(&moveOperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_serversEnabled) {
|
if (!_serverlessDomain) {
|
||||||
// send add-entity packets to the server
|
// send add-entity packets to the server
|
||||||
i = map.begin();
|
i = map.begin();
|
||||||
while (i != map.end()) {
|
while (i != map.end()) {
|
||||||
|
|
|
@ -283,8 +283,8 @@ public:
|
||||||
|
|
||||||
void setMyAvatar(std::shared_ptr<AvatarData> myAvatar) { _myAvatar = myAvatar; }
|
void setMyAvatar(std::shared_ptr<AvatarData> myAvatar) { _myAvatar = myAvatar; }
|
||||||
|
|
||||||
void setIsServerlessMode(bool value) { _serversEnabled = !value; }
|
void setIsServerlessMode(bool value) { _serverlessDomain = value; }
|
||||||
bool isServerlessMode() const { return !_serversEnabled; }
|
bool isServerlessMode() const { return _serverlessDomain; }
|
||||||
|
|
||||||
static void setAddMaterialToEntityOperator(std::function<bool(const QUuid&, graphics::MaterialLayer, const std::string&)> addMaterialToEntityOperator) { _addMaterialToEntityOperator = addMaterialToEntityOperator; }
|
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; }
|
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::MaterialLayer, const std::string&)> _addMaterialToOverlayOperator;
|
||||||
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 _serversEnabled { true };
|
bool _serverlessDomain { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_EntityTree_h
|
#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);
|
Setting::Handle<QUrl> currentAddressHandle(QStringList() << ADDRESS_MANAGER_SETTINGS_GROUP << "address", DEFAULT_HIFI_ADDRESS);
|
||||||
|
|
||||||
AddressManager::AddressManager() :
|
|
||||||
_port(0)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AddressManager::protocolVersion() {
|
QString AddressManager::protocolVersion() {
|
||||||
return protocolVersionsSignatureBase64();
|
return protocolVersionsSignatureBase64();
|
||||||
}
|
}
|
||||||
|
@ -56,18 +50,7 @@ bool AddressManager::isConnected() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl AddressManager::currentAddress(bool domainOnly) const {
|
QUrl AddressManager::currentAddress(bool domainOnly) const {
|
||||||
QUrl hifiURL;
|
QUrl hifiURL = _domainURL;
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!domainOnly && hifiURL.scheme() == HIFI_URL_SCHEME) {
|
if (!domainOnly && hifiURL.scheme() == HIFI_URL_SCHEME) {
|
||||||
hifiURL.setPath(currentPath());
|
hifiURL.setPath(currentPath());
|
||||||
|
@ -219,7 +202,7 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
|
||||||
|
|
||||||
if (lookupUrl.scheme() == HIFI_URL_SCHEME) {
|
if (lookupUrl.scheme() == HIFI_URL_SCHEME) {
|
||||||
|
|
||||||
emit setServersEnabled(true);
|
emit setServerlessDomain(false);
|
||||||
|
|
||||||
qCDebug(networking) << "Trying to go to URL" << lookupUrl.toString();
|
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") {
|
} else if (lookupUrl.scheme() == "http" || lookupUrl.scheme() == "https" || lookupUrl.scheme() == "file") {
|
||||||
_previousLookup.clear();
|
_previousLookup.clear();
|
||||||
QUrl domainUrl = PathUtils::expandToLocalDataAbsolutePath(lookupUrl);
|
QUrl domainUrl = PathUtils::expandToLocalDataAbsolutePath(lookupUrl);
|
||||||
emit setServersEnabled(false);
|
emit setServerlessDomain(true);
|
||||||
setDomainInfo(domainUrl, QString(), 0, trigger);
|
setDomainInfo(domainUrl, trigger);
|
||||||
DependencyManager::get<NodeList>()->getDomainHandler().setIsConnected(true);
|
DependencyManager::get<NodeList>()->getDomainHandler().setIsConnected(true);
|
||||||
emit lookupResultsFinished();
|
emit lookupResultsFinished();
|
||||||
return true;
|
return true;
|
||||||
|
@ -417,7 +400,11 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const
|
||||||
|
|
||||||
qCDebug(networking) << "Possible domain change required to connect to" << domainHostname
|
qCDebug(networking) << "Possible domain change required to connect to" << domainHostname
|
||||||
<< "on" << domainPort;
|
<< "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 {
|
} else {
|
||||||
QString iceServerAddress = domainObject[DOMAIN_ICE_SERVER_ADDRESS_KEY].toString();
|
QString iceServerAddress = domainObject[DOMAIN_ICE_SERVER_ADDRESS_KEY].toString();
|
||||||
|
|
||||||
|
@ -454,15 +441,10 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const
|
||||||
if (setHost(placeName, trigger)) {
|
if (setHost(placeName, trigger)) {
|
||||||
trigger = LookupTrigger::Internal;
|
trigger = LookupTrigger::Internal;
|
||||||
}
|
}
|
||||||
|
|
||||||
_placeName = placeName;
|
|
||||||
} else {
|
} else {
|
||||||
if (setHost(domainIDString, trigger)) {
|
if (setHost(domainIDString, trigger)) {
|
||||||
trigger = LookupTrigger::Internal;
|
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
|
// check if we had a path to override the path returned
|
||||||
|
@ -589,7 +571,11 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString, LookupTri
|
||||||
}
|
}
|
||||||
|
|
||||||
emit lookupResultsFinished();
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -606,7 +592,11 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString, LookupTri
|
||||||
}
|
}
|
||||||
|
|
||||||
emit lookupResultsFinished();
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -730,17 +720,19 @@ bool AddressManager::handleUsername(const QString& lookupString) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddressManager::setHost(const QString& host, LookupTrigger trigger, quint16 port) {
|
bool AddressManager::setHost(const QString& host, LookupTrigger trigger, quint16 port) {
|
||||||
if (host != _host || port != _port) {
|
if (host != _domainURL.host() || port != _domainURL.port()) {
|
||||||
addCurrentAddressToHistory(trigger);
|
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
|
// any host change should clear the shareable place name
|
||||||
_shareablePlaceName.clear();
|
_shareablePlaceName.clear();
|
||||||
_serverlessDomainURL = QUrl();
|
|
||||||
|
|
||||||
if (host != _host) {
|
if (emitHostChanged) {
|
||||||
_host = host;
|
emit hostChanged(host);
|
||||||
emit hostChanged(_host);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -749,26 +741,43 @@ bool AddressManager::setHost(const QString& host, LookupTrigger trigger, quint16
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddressManager::setDomainInfo(const QUrl& serverlessDomainURL,
|
QString AddressManager::getHost() const {
|
||||||
const QString& hostname, quint16 port, LookupTrigger trigger) {
|
if (isPossiblePlaceName(_domainURL.host())) {
|
||||||
bool hostChanged = setHost(hostname, trigger, port);
|
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
|
// clear any current place information
|
||||||
_rootPlaceID = QUuid();
|
_rootPlaceID = QUuid();
|
||||||
_placeName.clear();
|
|
||||||
_serverlessDomainURL = serverlessDomainURL;
|
|
||||||
|
|
||||||
if (!serverlessDomainURL.isEmpty()) {
|
if (_domainURL.scheme() == HIFI_URL_SCHEME) {
|
||||||
qCDebug(networking) << "Possible domain change required to serverless domain: " << serverlessDomainURL.toString();
|
|
||||||
} else {
|
|
||||||
qCDebug(networking) << "Possible domain change required to connect to domain at" << hostname << "on" << port;
|
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);
|
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) {
|
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
|
// 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
|
// 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;
|
JSONCallbackParameters callbackParams;
|
||||||
|
|
||||||
// no error callback handling
|
// 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"
|
#include "AccountManager.h"
|
||||||
|
|
||||||
const QString HIFI_URL_SCHEME = "hifi";
|
|
||||||
|
|
||||||
extern const QString DEFAULT_HIFI_ADDRESS;
|
extern const QString DEFAULT_HIFI_ADDRESS;
|
||||||
|
|
||||||
const QString SANDBOX_HIFI_ADDRESS = "hifi://localhost";
|
const QString SANDBOX_HIFI_ADDRESS = "hifi://localhost";
|
||||||
|
@ -166,10 +164,10 @@ public:
|
||||||
QString currentFacingPath() const;
|
QString currentFacingPath() const;
|
||||||
|
|
||||||
const QUuid& getRootPlaceID() const { return _rootPlaceID; }
|
const QUuid& getRootPlaceID() const { return _rootPlaceID; }
|
||||||
const QString& getPlaceName() const { return _shareablePlaceName.isEmpty() ? _placeName : _shareablePlaceName; }
|
QString getPlaceName() const;
|
||||||
QString getDomainID() const;
|
QString getDomainID() const;
|
||||||
|
|
||||||
const QString& getHost() const { return _host; }
|
QString getHost() const;
|
||||||
|
|
||||||
void setPositionGetter(PositionGetter positionGetter) { _positionGetter = positionGetter; }
|
void setPositionGetter(PositionGetter positionGetter) { _positionGetter = positionGetter; }
|
||||||
void setOrientationGetter(OrientationGetter orientationGetter) { _orientationGetter = orientationGetter; }
|
void setOrientationGetter(OrientationGetter orientationGetter) { _orientationGetter = orientationGetter; }
|
||||||
|
@ -179,7 +177,7 @@ public:
|
||||||
const QStack<QUrl>& getBackStack() const { return _backStack; }
|
const QStack<QUrl>& getBackStack() const { return _backStack; }
|
||||||
const QStack<QUrl>& getForwardStack() const { return _forwardStack; }
|
const QStack<QUrl>& getForwardStack() const { return _forwardStack; }
|
||||||
|
|
||||||
QUrl getServerlessDomainURL() { return _serverlessDomainURL; }
|
QUrl getDomainURL() { return _domainURL; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
|
@ -313,15 +311,12 @@ signals:
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Triggered when a request is made to go to an IP address.
|
* Triggered when a request is made to go to an IP address.
|
||||||
* @function location.possibleDomainChangeRequired
|
* @function location.possibleDomainChangeRequired
|
||||||
* @param {string} serverlessDomainURL - URL for a file-based domain
|
* @param {Url} domainURL - URL for 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 {Uuid} domainID - The UUID of the domain to go to.
|
* @param {Uuid} domainID - The UUID of the domain to go to.
|
||||||
* @returns {Signal}
|
* @returns {Signal}
|
||||||
*/
|
*/
|
||||||
// No example because this function isn't typically used in scripts.
|
// No example because this function isn't typically used in scripts.
|
||||||
void possibleDomainChangeRequired(const QUrl& serverlessDomainURL,
|
void possibleDomainChangeRequired(QUrl domainURL, QUuid domainID);
|
||||||
const QString& newHostname, quint16 newPort, const QUuid& domainID);
|
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Triggered when a request is made to go to a named domain or user.
|
* Triggered when a request is made to go to a named domain or user.
|
||||||
|
@ -420,11 +415,9 @@ signals:
|
||||||
*/
|
*/
|
||||||
void goForwardPossible(bool isPossible);
|
void goForwardPossible(bool isPossible);
|
||||||
|
|
||||||
void setServersEnabled(bool serversEnabled);
|
void setServerlessDomain(bool serverlessDomain);
|
||||||
void loadServerlessDomain(QUrl domainURL);
|
void loadServerlessDomain(QUrl domainURL);
|
||||||
|
|
||||||
protected:
|
|
||||||
AddressManager();
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleAPIResponse(QNetworkReply& requestReply);
|
void handleAPIResponse(QNetworkReply& requestReply);
|
||||||
void handleAPIError(QNetworkReply& errorReply);
|
void handleAPIError(QNetworkReply& errorReply);
|
||||||
|
@ -436,7 +429,7 @@ private:
|
||||||
|
|
||||||
// Set host and port, and return `true` if it was changed.
|
// Set host and port, and return `true` if it was changed.
|
||||||
bool setHost(const QString& host, LookupTrigger trigger, quint16 port = 0);
|
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();
|
const JSONCallbackParameters& apiCallbackParameters();
|
||||||
|
|
||||||
|
@ -454,10 +447,8 @@ private:
|
||||||
|
|
||||||
void addCurrentAddressToHistory(LookupTrigger trigger);
|
void addCurrentAddressToHistory(LookupTrigger trigger);
|
||||||
|
|
||||||
QString _host;
|
QUrl _domainURL;
|
||||||
quint16 _port;
|
|
||||||
QString _placeName;
|
|
||||||
QUrl _serverlessDomainURL; // for file-based domains
|
|
||||||
QUuid _rootPlaceID;
|
QUuid _rootPlaceID;
|
||||||
PositionGetter _positionGetter;
|
PositionGetter _positionGetter;
|
||||||
OrientationGetter _orientationGetter;
|
OrientationGetter _orientationGetter;
|
||||||
|
|
|
@ -115,9 +115,8 @@ void DomainHandler::hardReset() {
|
||||||
qCDebug(networking) << "Hard reset in NodeList DomainHandler.";
|
qCDebug(networking) << "Hard reset in NodeList DomainHandler.";
|
||||||
_pendingDomainID = QUuid();
|
_pendingDomainID = QUuid();
|
||||||
_iceServerSockAddr = HifiSockAddr();
|
_iceServerSockAddr = HifiSockAddr();
|
||||||
_hostname = QString();
|
|
||||||
_sockAddr.clear();
|
_sockAddr.clear();
|
||||||
_serverlessDomainURL = QUrl();
|
_domainURL = QUrl();
|
||||||
|
|
||||||
_domainConnectionRefusals.clear();
|
_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
|
// some callers may pass a hostname, this is not to be used for lookup but for DTLS certificate verification
|
||||||
_hostname = hostname;
|
_domainURL = QUrl();
|
||||||
_serverlessDomainURL = QUrl();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainHandler::setUUID(const QUuid& uuid) {
|
void DomainHandler::setUUID(const QUuid& uuid) {
|
||||||
|
@ -151,42 +149,37 @@ void DomainHandler::setUUID(const QUuid& uuid) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainHandler::setSocketAndID(const QUrl& serverlessDomainURL,
|
void DomainHandler::setURLAndID(QUrl domainURL, QUuid domainID) {
|
||||||
const QString& hostname, quint16 port, const QUuid& domainID) {
|
|
||||||
|
|
||||||
_pendingDomainID = 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
|
// re-set the domain info so that auth information is reloaded
|
||||||
hardReset();
|
hardReset();
|
||||||
|
|
||||||
if (serverlessDomainURL != _serverlessDomainURL) {
|
QString hostname = domainURL.host();
|
||||||
_serverlessDomainURL = serverlessDomainURL;
|
quint16 port = domainURL.port();
|
||||||
if (_serverlessDomainURL != QUrl()) {
|
|
||||||
setIsConnected(true);
|
|
||||||
}
|
|
||||||
emit serverlessDomainChanged(_serverlessDomainURL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hostname != _hostname) {
|
_domainURL = domainURL;
|
||||||
// set the new hostname
|
|
||||||
_hostname = hostname;
|
|
||||||
|
|
||||||
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
|
// 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());
|
qCDebug(networking, "Looking up DS hostname %s.", hostname.toLocal8Bit().constData());
|
||||||
QHostInfo::lookupHost(_hostname, this, SLOT(completedHostnameLookup(const QHostInfo&)));
|
QHostInfo::lookupHost(hostname, this, SLOT(completedHostnameLookup(const QHostInfo&)));
|
||||||
|
|
||||||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(
|
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(
|
||||||
LimitedNodeList::ConnectionStep::SetDomainHostname);
|
LimitedNodeList::ConnectionStep::SetDomainHostname);
|
||||||
|
|
||||||
UserActivityLogger::getInstance().changedDomain(_hostname);
|
UserActivityLogger::getInstance().changedDomain(hostname);
|
||||||
}
|
}
|
||||||
emit hostnameChanged(_hostname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit domainURLChanged(_domainURL);
|
||||||
|
|
||||||
if (_sockAddr.getPort() != port) {
|
if (_sockAddr.getPort() != port) {
|
||||||
qCDebug(networking) << "Updated domain port to" << 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) {
|
void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname, const QUuid& id) {
|
||||||
|
|
||||||
if (_serverlessDomainURL != QUrl()) {
|
if (isServerless()) {
|
||||||
_serverlessDomainURL = QUrl();
|
// if we were connected to a serverless domain, clear the octree, etc
|
||||||
emit serverlessDomainChanged(QUrl());
|
_domainURL = QUrl();
|
||||||
|
emit domainURLChanged(_domainURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_iceServerSockAddr.getAddress().toString() != iceServerHostname || id != _pendingDomainID) {
|
if (_iceServerSockAddr.getAddress().toString() != iceServerHostname || id != _pendingDomainID) {
|
||||||
|
@ -235,16 +229,16 @@ void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname,
|
||||||
void DomainHandler::activateICELocalSocket() {
|
void DomainHandler::activateICELocalSocket() {
|
||||||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket);
|
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket);
|
||||||
_sockAddr = _icePeer.getLocalSocket();
|
_sockAddr = _icePeer.getLocalSocket();
|
||||||
_hostname = _sockAddr.getAddress().toString();
|
_domainURL.setScheme(HIFI_URL_SCHEME);
|
||||||
_serverlessDomainURL = QUrl();
|
_domainURL.setHost(_sockAddr.getAddress().toString());
|
||||||
emit completedSocketDiscovery();
|
emit completedSocketDiscovery();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainHandler::activateICEPublicSocket() {
|
void DomainHandler::activateICEPublicSocket() {
|
||||||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket);
|
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket);
|
||||||
_sockAddr = _icePeer.getPublicSocket();
|
_sockAddr = _icePeer.getPublicSocket();
|
||||||
_hostname = _sockAddr.getAddress().toString();
|
_domainURL.setScheme(HIFI_URL_SCHEME);
|
||||||
_serverlessDomainURL = QUrl();
|
_domainURL.setHost(_sockAddr.getAddress().toString());
|
||||||
emit completedSocketDiscovery();
|
emit completedSocketDiscovery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +249,7 @@ void DomainHandler::completedHostnameLookup(const QHostInfo& hostInfo) {
|
||||||
|
|
||||||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket);
|
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());
|
_sockAddr.getAddress().toString().toLocal8Bit().constData());
|
||||||
|
|
||||||
emit completedSocketDiscovery();
|
emit completedSocketDiscovery();
|
||||||
|
@ -282,9 +276,9 @@ void DomainHandler::setIsConnected(bool isConnected) {
|
||||||
_isConnected = isConnected;
|
_isConnected = isConnected;
|
||||||
|
|
||||||
if (_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
|
// we've connected to new domain - time to ask it for global settings
|
||||||
requestDomainSettings();
|
requestDomainSettings();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "NLPacketList.h"
|
#include "NLPacketList.h"
|
||||||
#include "Node.h"
|
#include "Node.h"
|
||||||
#include "ReceivedMessage.h"
|
#include "ReceivedMessage.h"
|
||||||
|
#include "NetworkingConstants.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;
|
||||||
|
@ -44,7 +45,7 @@ public:
|
||||||
const QUuid& getUUID() const { return _uuid; }
|
const QUuid& getUUID() const { return _uuid; }
|
||||||
void setUUID(const QUuid& 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(); }
|
const QHostAddress& getIP() const { return _sockAddr.getAddress(); }
|
||||||
void setIPToLocalhost() { _sockAddr.setAddress(QHostAddress(QHostAddress::LocalHost)); }
|
void setIPToLocalhost() { _sockAddr.setAddress(QHostAddress(QHostAddress::LocalHost)); }
|
||||||
|
@ -73,7 +74,7 @@ public:
|
||||||
|
|
||||||
bool isConnected() const { return _isConnected; }
|
bool isConnected() const { return _isConnected; }
|
||||||
void setIsConnected(bool 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(); }
|
bool hasSettings() const { return !_settingsObject.isEmpty(); }
|
||||||
void requestDomainSettings();
|
void requestDomainSettings();
|
||||||
|
@ -140,8 +141,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setSocketAndID(const QUrl& serverlessDomainURL,
|
void setURLAndID(QUrl domainURL, QUuid id);
|
||||||
const QString& hostname, quint16 port = DEFAULT_DOMAIN_SERVER_PORT, const QUuid& id = QUuid());
|
|
||||||
void setIceServerHostnameAndID(const QString& iceServerHostname, const QUuid& id);
|
void setIceServerHostnameAndID(const QString& iceServerHostname, const QUuid& id);
|
||||||
|
|
||||||
void processSettingsPacketList(QSharedPointer<ReceivedMessage> packetList);
|
void processSettingsPacketList(QSharedPointer<ReceivedMessage> packetList);
|
||||||
|
@ -155,15 +155,14 @@ private slots:
|
||||||
void completedIceServerHostnameLookup();
|
void completedIceServerHostnameLookup();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void hostnameChanged(const QString& hostname);
|
void domainURLChanged(QUrl domainURL);
|
||||||
void serverlessDomainChanged(QUrl serverlessDomainURL);
|
|
||||||
|
|
||||||
// NOTE: the emission of completedSocketDiscovery does not mean a connection to DS is established
|
// 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
|
// It means that, either from DNS lookup or ICE, we think we have a socket we can talk to DS on
|
||||||
void completedSocketDiscovery();
|
void completedSocketDiscovery();
|
||||||
|
|
||||||
void resetting();
|
void resetting();
|
||||||
void connectedToDomain(const QString& hostname, const QUrl& serverlessDomainURL);
|
void connectedToDomain(QUrl domainURL);
|
||||||
void disconnectedFromDomain();
|
void disconnectedFromDomain();
|
||||||
|
|
||||||
void iceSocketAndIDReceived();
|
void iceSocketAndIDReceived();
|
||||||
|
@ -182,8 +181,7 @@ private:
|
||||||
void hardReset();
|
void hardReset();
|
||||||
|
|
||||||
QUuid _uuid;
|
QUuid _uuid;
|
||||||
QUrl _serverlessDomainURL;
|
QUrl _domainURL;
|
||||||
QString _hostname;
|
|
||||||
HifiSockAddr _sockAddr;
|
HifiSockAddr _sockAddr;
|
||||||
QUuid _assignmentUUID;
|
QUuid _assignmentUUID;
|
||||||
QUuid _connectionToken;
|
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
|
// if you manually generate a personal access token for the domains scope
|
||||||
// at https://staging.highfidelity.com/user/tokens/new?for_domain_server=true
|
// at https://staging.highfidelity.com/user/tokens/new?for_domain_server=true
|
||||||
|
|
||||||
const QUrl METAVERSE_SERVER_URL_STABLE("https://metaverse.highfidelity.com");
|
QUrl METAVERSE_SERVER_URL_STABLE();
|
||||||
const QUrl METAVERSE_SERVER_URL_STAGING("https://staging.highfidelity.com");
|
QUrl METAVERSE_SERVER_URL_STAGING();
|
||||||
|
QUrl METAVERSE_SERVER_URL();
|
||||||
// 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;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString HIFI_URL_SCHEME = "hifi";
|
||||||
|
|
||||||
#endif // hifi_NetworkingConstants_h
|
#endif // hifi_NetworkingConstants_h
|
||||||
|
|
|
@ -55,7 +55,7 @@ NodeList::NodeList(char newOwnerType, int socketListenPort, int dtlsListenPort)
|
||||||
|
|
||||||
// handle domain change signals from AddressManager
|
// handle domain change signals from AddressManager
|
||||||
connect(addressManager.data(), &AddressManager::possibleDomainChangeRequired,
|
connect(addressManager.data(), &AddressManager::possibleDomainChangeRequired,
|
||||||
&_domainHandler, &DomainHandler::setSocketAndID);
|
&_domainHandler, &DomainHandler::setURLAndID);
|
||||||
|
|
||||||
connect(addressManager.data(), &AddressManager::possibleDomainChangeRequiredViaICEForID,
|
connect(addressManager.data(), &AddressManager::possibleDomainChangeRequiredViaICEForID,
|
||||||
&_domainHandler, &DomainHandler::setIceServerHostnameAndID);
|
&_domainHandler, &DomainHandler::setIceServerHostnameAndID);
|
||||||
|
@ -91,7 +91,7 @@ NodeList::NodeList(char newOwnerType, int socketListenPort, int dtlsListenPort)
|
||||||
connect(accountManager.data(), &AccountManager::newKeypair, this, &NodeList::sendDomainServerCheckIn);
|
connect(accountManager.data(), &AccountManager::newKeypair, this, &NodeList::sendDomainServerCheckIn);
|
||||||
|
|
||||||
// clear out NodeList when login is finished
|
// 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
|
// clear our NodeList when logout is requested
|
||||||
connect(accountManager.data(), SIGNAL(logoutComplete()) , this, SLOT(reset()));
|
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)
|
// 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
|
_keepAlivePingTimer.setInterval(KEEPALIVE_PING_INTERVAL_MS); // 1s, Qt::CoarseTimer acceptable
|
||||||
connect(&_keepAlivePingTimer, &QTimer::timeout, this, &NodeList::sendKeepAlivePings);
|
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);
|
connect(&_domainHandler, &DomainHandler::disconnectedFromDomain, &_keepAlivePingTimer, &QTimer::stop);
|
||||||
|
|
||||||
// set our sockAddrBelongsToDomainOrNode method as the connection creation filter for the udt::Socket
|
// 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();
|
nodeList->startThread();
|
||||||
|
|
||||||
const DomainHandler& domainHandler = nodeList->getDomainHandler();
|
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(&domainHandler, &DomainHandler::domainConnectionRefused, this, &ACClientApp::domainConnectionRefused);
|
||||||
|
|
||||||
connect(nodeList.data(), &NodeList::nodeAdded, this, &ACClientApp::nodeAdded);
|
connect(nodeList.data(), &NodeList::nodeAdded, this, &ACClientApp::nodeAdded);
|
||||||
|
@ -169,7 +169,7 @@ void ACClientApp::domainConnectionRefused(const QString& reasonMessage, int reas
|
||||||
qDebug() << "domainConnectionRefused";
|
qDebug() << "domainConnectionRefused";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACClientApp::domainChanged(const QString& domainHostname) {
|
void ACClientApp::domainChanged(QUrl domainURL) {
|
||||||
if (_verbose) {
|
if (_verbose) {
|
||||||
qDebug() << "domainChanged";
|
qDebug() << "domainChanged";
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ public:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo);
|
void domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo);
|
||||||
void domainChanged(const QString& domainHostname);
|
void domainChanged(QUrl domainURL);
|
||||||
void nodeAdded(SharedNodePointer node);
|
void nodeAdded(SharedNodePointer node);
|
||||||
void nodeActivated(SharedNodePointer node);
|
void nodeActivated(SharedNodePointer node);
|
||||||
void nodeKilled(SharedNodePointer node);
|
void nodeKilled(SharedNodePointer node);
|
||||||
|
|
|
@ -158,7 +158,7 @@ ATPClientApp::ATPClientApp(int argc, char* argv[]) :
|
||||||
nodeList->startThread();
|
nodeList->startThread();
|
||||||
|
|
||||||
const DomainHandler& domainHandler = nodeList->getDomainHandler();
|
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(&domainHandler, &DomainHandler::domainConnectionRefused, this, &ATPClientApp::domainConnectionRefused);
|
||||||
|
|
||||||
connect(nodeList.data(), &NodeList::nodeAdded, this, &ATPClientApp::nodeAdded);
|
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) {
|
if (_verbose) {
|
||||||
qDebug() << "domainChanged";
|
qDebug() << "domainChanged";
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo);
|
void domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo);
|
||||||
void domainChanged(const QString& domainHostname);
|
void domainChanged(QUrl domainURL);
|
||||||
void nodeAdded(SharedNodePointer node);
|
void nodeAdded(SharedNodePointer node);
|
||||||
void nodeActivated(SharedNodePointer node);
|
void nodeActivated(SharedNodePointer node);
|
||||||
void nodeKilled(SharedNodePointer node);
|
void nodeKilled(SharedNodePointer node);
|
||||||
|
|
Loading…
Reference in a new issue