mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 02:23:57 +02:00
adding working version with networking signals
This commit is contained in:
parent
b6d23843dd
commit
c95cb97b9b
7 changed files with 891 additions and 834 deletions
File diff suppressed because it is too large
Load diff
|
@ -1185,6 +1185,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
const DomainHandler& domainHandler = nodeList->getDomainHandler();
|
||||
|
||||
connect(&domainHandler, SIGNAL(domainURLChanged(QUrl)), SLOT(domainURLChanged(QUrl)));
|
||||
connect(&domainHandler, SIGNAL(redirectToErrorDomainURL(QUrl)), SLOT(goToErrorDomainURL(QUrl)));
|
||||
connect(&domainHandler, &DomainHandler::domainURLChanged, [](QUrl domainURL){
|
||||
setCrashAnnotation("domain", domainURL.toString().toStdString());
|
||||
});
|
||||
|
@ -2251,6 +2252,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
|
||||
connect(this, &QCoreApplication::aboutToQuit, this, &Application::addAssetToWorldMessageClose);
|
||||
connect(&domainHandler, &DomainHandler::domainURLChanged, this, &Application::addAssetToWorldMessageClose);
|
||||
connect(&domainHandler, &DomainHandler::redirectToErrorDomainURL, this, &Application::addAssetToWorldMessageClose);
|
||||
|
||||
updateSystemTabletMode();
|
||||
|
||||
|
@ -2343,14 +2345,6 @@ void Application::domainConnectionRefused(const QString& reasonMessage, int reas
|
|||
}
|
||||
}
|
||||
|
||||
void Application::domainConnectionRedirect() {
|
||||
auto addressManager = DependencyManager::get<AddressManager>();
|
||||
|
||||
addressManager->handleLookupString(REDIRECT_HIFI_ADDRESS);
|
||||
getMyAvatar()->setWorldVelocity(glm::vec3(0.0f));
|
||||
}
|
||||
|
||||
|
||||
QString Application::getUserAgent() {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QString userAgent;
|
||||
|
@ -3481,7 +3475,7 @@ void Application::setIsServerlessMode(bool serverlessDomain) {
|
|||
}
|
||||
}
|
||||
|
||||
void Application::loadServerlessDomain(QUrl domainURL) {
|
||||
void Application::loadServerlessDomain(QUrl domainURL, bool errorDomain) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "loadServerlessDomain", Q_ARG(QUrl, domainURL));
|
||||
return;
|
||||
|
@ -3515,8 +3509,11 @@ void Application::loadServerlessDomain(QUrl domainURL) {
|
|||
}
|
||||
|
||||
std::map<QString, QString> namedPaths = tmpTree->getNamedPaths();
|
||||
nodeList->getDomainHandler().connectedToServerless(namedPaths);
|
||||
|
||||
if (errorDomain) {
|
||||
nodeList->getDomainHandler().loadedErrorDomain(namedPaths);
|
||||
} else {
|
||||
nodeList->getDomainHandler().connectedToServerless(namedPaths);
|
||||
}
|
||||
|
||||
_fullSceneReceivedCounter++;
|
||||
}
|
||||
|
@ -6381,6 +6378,7 @@ void Application::clearDomainAvatars() {
|
|||
void Application::domainURLChanged(QUrl domainURL) {
|
||||
// disable physics until we have enough information about our new location to not cause craziness.
|
||||
resetPhysicsReadyInformation();
|
||||
auto urlStr = domainURL.toString().toStdString();
|
||||
setIsServerlessMode(domainURL.scheme() != URL_SCHEME_HIFI);
|
||||
if (isServerlessMode()) {
|
||||
loadServerlessDomain(domainURL);
|
||||
|
@ -6388,6 +6386,17 @@ void Application::domainURLChanged(QUrl domainURL) {
|
|||
updateWindowTitle();
|
||||
}
|
||||
|
||||
void Application::goToErrorDomainURL(QUrl errorDomainURL) {
|
||||
// disable physics until we have enough information about our new location to not cause craziness.
|
||||
resetPhysicsReadyInformation();
|
||||
auto urlStr = errorDomainURL.toString().toStdString();
|
||||
setIsServerlessMode(errorDomainURL.scheme() != URL_SCHEME_HIFI);
|
||||
if (isServerlessMode()) {
|
||||
loadServerlessDomain(errorDomainURL, true);
|
||||
}
|
||||
updateWindowTitle();
|
||||
}
|
||||
|
||||
|
||||
void Application::resettingDomain() {
|
||||
_notifiedPacketVersionMismatchThisDomain = false;
|
||||
|
|
|
@ -426,7 +426,7 @@ public slots:
|
|||
void setPreferredCursor(const QString& cursor);
|
||||
|
||||
void setIsServerlessMode(bool serverlessDomain);
|
||||
void loadServerlessDomain(QUrl domainURL);
|
||||
void loadServerlessDomain(QUrl domainURL, bool errorDomain = false);
|
||||
|
||||
void updateVerboseLogging();
|
||||
|
||||
|
@ -465,6 +465,7 @@ private slots:
|
|||
void setSessionUUID(const QUuid& sessionUUID) const;
|
||||
|
||||
void domainURLChanged(QUrl domainURL);
|
||||
void goToErrorDomainURL(QUrl errorDomainURL);
|
||||
void updateWindowTitle() const;
|
||||
void nodeAdded(SharedNodePointer node) const;
|
||||
void nodeActivated(SharedNodePointer node);
|
||||
|
@ -474,7 +475,6 @@ private slots:
|
|||
void updateDisplayMode();
|
||||
void setDisplayPlugin(DisplayPluginPointer newPlugin);
|
||||
void domainConnectionRefused(const QString& reasonMessage, int reason, const QString& extraInfo);
|
||||
void domainConnectionRedirect();
|
||||
|
||||
void addAssetToWorldCheckModelSize();
|
||||
|
||||
|
|
|
@ -114,6 +114,9 @@ QUrl AddressManager::currentFacingPublicAddress() const {
|
|||
return shareableAddress;
|
||||
}
|
||||
|
||||
QUrl AddressManager::lastAddress() const {
|
||||
return _lastVisitedURL;
|
||||
}
|
||||
|
||||
void AddressManager::loadSettings(const QString& lookupString) {
|
||||
#if defined(USE_GLES) && defined(Q_OS_WIN)
|
||||
|
@ -151,6 +154,12 @@ void AddressManager::goForward() {
|
|||
}
|
||||
}
|
||||
|
||||
void AddressManager::goToLastAddress() {
|
||||
// this should always return something as long as the URL isn't empty.
|
||||
auto urlStr = _lastVisitedURL.toString().toStdString();
|
||||
handleUrl(_lastVisitedURL, LookupTrigger::AttemptedRefresh);
|
||||
}
|
||||
|
||||
void AddressManager::storeCurrentAddress() {
|
||||
auto url = currentAddress();
|
||||
|
||||
|
@ -250,9 +259,12 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
|
|||
|
||||
UserActivityLogger::getInstance().wentTo(trigger, URL_TYPE_USER, lookupUrl.toString());
|
||||
|
||||
// save the last visited domain URL.
|
||||
_lastVisitedURL = lookupUrl;
|
||||
|
||||
// in case we're failing to connect to where we thought this user was
|
||||
// store their username as previous lookup so we can refresh their location via API
|
||||
_previousLookup = lookupUrl;
|
||||
_previousAPILookup = lookupUrl;
|
||||
} else {
|
||||
// we're assuming this is either a network address or global place name
|
||||
// check if it is a network address first
|
||||
|
@ -262,8 +274,11 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
|
|||
|
||||
UserActivityLogger::getInstance().wentTo(trigger, URL_TYPE_NETWORK_ADDRESS, lookupUrl.toString());
|
||||
|
||||
// save the last visited domain URL.
|
||||
_lastVisitedURL = lookupUrl;
|
||||
|
||||
// a network address lookup clears the previous lookup since we don't expect to re-attempt it
|
||||
_previousLookup.clear();
|
||||
_previousAPILookup.clear();
|
||||
|
||||
// If the host changed then we have already saved to history
|
||||
if (hostChanged) {
|
||||
|
@ -281,8 +296,11 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
|
|||
} else if (handleDomainID(lookupUrl.host())){
|
||||
UserActivityLogger::getInstance().wentTo(trigger, URL_TYPE_DOMAIN_ID, lookupUrl.toString());
|
||||
|
||||
// save the last visited domain URL.
|
||||
_lastVisitedURL = lookupUrl;
|
||||
|
||||
// store this domain ID as the previous lookup in case we're failing to connect and want to refresh API info
|
||||
_previousLookup = lookupUrl;
|
||||
_previousAPILookup = lookupUrl;
|
||||
|
||||
// no place name - this is probably a domain ID
|
||||
// try to look up the domain ID on the metaverse API
|
||||
|
@ -290,8 +308,11 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
|
|||
} else {
|
||||
UserActivityLogger::getInstance().wentTo(trigger, URL_TYPE_PLACE, lookupUrl.toString());
|
||||
|
||||
// save the last visited domain URL.
|
||||
_lastVisitedURL = lookupUrl;
|
||||
|
||||
// store this place name as the previous lookup in case we fail to connect and want to refresh API info
|
||||
_previousLookup = lookupUrl;
|
||||
_previousAPILookup = lookupUrl;
|
||||
|
||||
// wasn't an address - lookup the place name
|
||||
// we may have a path that defines a relative viewpoint - pass that through the lookup so we can go to it after
|
||||
|
@ -305,7 +326,7 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
|
|||
qCDebug(networking) << "Going to relative path" << lookupUrl.path();
|
||||
|
||||
// a path lookup clears the previous lookup since we don't expect to re-attempt it
|
||||
_previousLookup.clear();
|
||||
_previousAPILookup.clear();
|
||||
|
||||
// if this is a relative path then handle it as a relative viewpoint
|
||||
handlePath(lookupUrl.path(), trigger, true);
|
||||
|
@ -317,7 +338,10 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
|
|||
// be loaded over http(s)
|
||||
// lookupUrl.scheme() == URL_SCHEME_HTTP ||
|
||||
// lookupUrl.scheme() == URL_SCHEME_HTTPS ||
|
||||
_previousLookup.clear();
|
||||
// TODO once a file can return a connection refusal if there were to be some kind of load error, we'd
|
||||
// need to store the previous domain tried in _lastVisitedURL. For now , do not store it.
|
||||
|
||||
_previousAPILookup.clear();
|
||||
_shareablePlaceName.clear();
|
||||
if (lookupUrl.toString() != REDIRECT_HIFI_ADDRESS) {
|
||||
setDomainInfo(lookupUrl, trigger);
|
||||
|
@ -386,7 +410,7 @@ void AddressManager::handleAPIResponse(QNetworkReply* requestReply) {
|
|||
QJsonObject dataObject = responseObject["data"].toObject();
|
||||
|
||||
// Lookup succeeded, don't keep re-trying it (especially on server restarts)
|
||||
_previousLookup.clear();
|
||||
_previousAPILookup.clear();
|
||||
|
||||
if (!dataObject.isEmpty()) {
|
||||
goToAddressFromObject(dataObject.toVariantMap(), requestReply);
|
||||
|
@ -552,7 +576,7 @@ void AddressManager::handleAPIError(QNetworkReply* errorReply) {
|
|||
|
||||
if (errorReply->error() == QNetworkReply::ContentNotFoundError) {
|
||||
// if this is a lookup that has no result, don't keep re-trying it
|
||||
_previousLookup.clear();
|
||||
_previousAPILookup.clear();
|
||||
|
||||
emit lookupResultIsNotFound();
|
||||
}
|
||||
|
@ -847,8 +871,8 @@ void AddressManager::goToUser(const QString& username, bool shouldMatchOrientati
|
|||
|
||||
void AddressManager::refreshPreviousLookup() {
|
||||
// if we have a non-empty previous lookup, fire it again now (but don't re-store it in the history)
|
||||
if (!_previousLookup.isEmpty()) {
|
||||
handleUrl(_previousLookup, LookupTrigger::AttemptedRefresh);
|
||||
if (!_previousAPILookup.isEmpty()) {
|
||||
handleUrl(_previousAPILookup, LookupTrigger::AttemptedRefresh);
|
||||
} else {
|
||||
handleUrl(currentAddress(), LookupTrigger::AttemptedRefresh);
|
||||
}
|
||||
|
|
|
@ -145,6 +145,7 @@ public:
|
|||
UserInput,
|
||||
Back,
|
||||
Forward,
|
||||
//Retry,
|
||||
StartupFromSettings,
|
||||
DomainPathResponse,
|
||||
Internal,
|
||||
|
@ -165,6 +166,8 @@ public:
|
|||
QString currentPath(bool withOrientation = true) const;
|
||||
QString currentFacingPath() const;
|
||||
|
||||
QUrl lastAddress() const;
|
||||
|
||||
const QUuid& getRootPlaceID() const { return _rootPlaceID; }
|
||||
QString getPlaceName() const;
|
||||
QString getDomainID() const;
|
||||
|
@ -246,6 +249,12 @@ public slots:
|
|||
*/
|
||||
void goToUser(const QString& username, bool shouldMatchOrientation = true);
|
||||
|
||||
/**jsdoc
|
||||
* Go to the last address tried. This will be the last URL tried from location.handleLookupString
|
||||
* @function location.goToLastAddress
|
||||
*/
|
||||
void goToLastAddress();
|
||||
|
||||
/**jsdoc
|
||||
* Refresh the current address, e.g., after connecting to a domain in order to position the user to the desired location.
|
||||
* @function location.refreshPreviousLookup
|
||||
|
@ -447,6 +456,7 @@ private:
|
|||
void addCurrentAddressToHistory(LookupTrigger trigger);
|
||||
|
||||
QUrl _domainURL;
|
||||
QUrl _lastVisitedURL;
|
||||
|
||||
QUuid _rootPlaceID;
|
||||
PositionGetter _positionGetter;
|
||||
|
@ -460,7 +470,7 @@ private:
|
|||
|
||||
QString _newHostLookupPath;
|
||||
|
||||
QUrl _previousLookup;
|
||||
QUrl _previousAPILookup;
|
||||
};
|
||||
|
||||
#endif // hifi_AddressManager_h
|
||||
|
|
|
@ -99,6 +99,7 @@ void DomainHandler::softReset() {
|
|||
|
||||
clearSettings();
|
||||
|
||||
_isInErrorState = false;
|
||||
_connectionDenialsSinceKeypairRegen = 0;
|
||||
_checkInPacketsSinceLastReply = 0;
|
||||
|
||||
|
@ -129,6 +130,7 @@ void DomainHandler::hardReset() {
|
|||
}
|
||||
|
||||
void DomainHandler::setErrorDomainURL(const QUrl& url) {
|
||||
_errorDomainURL = url;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -175,7 +177,8 @@ void DomainHandler::setURLAndID(QUrl domainURL, QUuid domainID) {
|
|||
domainPort = DEFAULT_DOMAIN_SERVER_PORT;
|
||||
}
|
||||
|
||||
if (_domainURL != domainURL || _sockAddr.getPort() != domainPort) {
|
||||
// if it's in the error state, reset and try again.
|
||||
if ((_domainURL != domainURL || _sockAddr.getPort() != domainPort) || _isInErrorState) {
|
||||
// re-set the domain info so that auth information is reloaded
|
||||
hardReset();
|
||||
|
||||
|
@ -210,7 +213,8 @@ void DomainHandler::setURLAndID(QUrl domainURL, QUuid domainID) {
|
|||
|
||||
void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname, const QUuid& id) {
|
||||
|
||||
if (_iceServerSockAddr.getAddress().toString() != iceServerHostname || id != _pendingDomainID) {
|
||||
// if it's in the error state, reset and try again.
|
||||
if ((_iceServerSockAddr.getAddress().toString() != iceServerHostname || id != _pendingDomainID) || _isInErrorState) {
|
||||
// re-set the domain info to connect to new domain
|
||||
hardReset();
|
||||
|
||||
|
@ -320,6 +324,17 @@ void DomainHandler::connectedToServerless(std::map<QString, QString> namedPaths)
|
|||
setIsConnected(true);
|
||||
}
|
||||
|
||||
void DomainHandler::loadedErrorDomain(std::map<QString, QString> namedPaths) {
|
||||
auto lookup = namedPaths.find("/");
|
||||
QString viewpoint;
|
||||
if (lookup != namedPaths.end()) {
|
||||
viewpoint = lookup->second;
|
||||
} else {
|
||||
viewpoint = DOMAIN_SPAWNING_POINT;
|
||||
}
|
||||
DependencyManager::get<AddressManager>()->goToViewpointForPath(viewpoint, QString());
|
||||
}
|
||||
|
||||
void DomainHandler::requestDomainSettings() {
|
||||
qCDebug(networking) << "Requesting settings from domain server";
|
||||
|
||||
|
@ -461,7 +476,7 @@ void DomainHandler::processDomainServerConnectionDeniedPacket(QSharedPointer<Rec
|
|||
if (reasonCode == ConnectionRefusedReason::ProtocolMismatch || reasonCode == ConnectionRefusedReason::NotAuthorized) {
|
||||
_isInErrorState = true;
|
||||
// ingest the error - this is a "hard" connection refusal.
|
||||
emit domainURLChanged(_errorDomainURL);
|
||||
emit redirectToErrorDomainURL(_errorDomainURL);
|
||||
} else {
|
||||
emit domainConnectionRefused(reasonMessage, (int)reasonCode, extraInfo);
|
||||
}
|
||||
|
|
|
@ -84,6 +84,8 @@ public:
|
|||
|
||||
void connectedToServerless(std::map<QString, QString> namedPaths);
|
||||
|
||||
void DomainHandler::loadedErrorDomain(std::map<QString, QString> namedPaths);
|
||||
|
||||
QString getViewPointFromNamedPath(QString namedPath);
|
||||
|
||||
bool hasSettings() const { return !_settingsObject.isEmpty(); }
|
||||
|
@ -182,7 +184,7 @@ signals:
|
|||
void settingsReceiveFail();
|
||||
|
||||
void domainConnectionRefused(QString reasonMessage, int reason, const QString& extraInfo);
|
||||
void redirectToErrorDomainURL();
|
||||
void redirectToErrorDomainURL(QUrl errorDomaunURL);
|
||||
|
||||
void limitOfSilentDomainCheckInsReached();
|
||||
|
||||
|
|
Loading…
Reference in a new issue