diff --git a/interface/src/Application.h b/interface/src/Application.h index aafc6a4f0d..0d569eed84 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -230,8 +230,6 @@ public: bool getPreferAvatarFingerOverStylus() { return false; } void setPreferAvatarFingerOverStylus(bool value); - float getDomainLoadingProgress() { return _octreeProcessor.domainLoadingProgress(); } - float getSettingConstrainToolbarPosition() { return _constrainToolbarPosition.get(); } void setSettingConstrainToolbarPosition(bool setting); diff --git a/interface/src/ConnectionMonitor.cpp b/interface/src/ConnectionMonitor.cpp index 2f4e135c9a..3fc353ec01 100644 --- a/interface/src/ConnectionMonitor.cpp +++ b/interface/src/ConnectionMonitor.cpp @@ -23,7 +23,6 @@ // should be longer to allow the application to initialize. static const int ON_INITIAL_LOAD_REDIRECT_AFTER_DISCONNECTED_FOR_X_MS = 10000; static const int REDIRECT_AFTER_DISCONNECTED_FOR_X_MS = 5000; -static const QString ERROR_DOMAIN_URL = "file:///~/serverless/redirect.json"; void ConnectionMonitor::init() { // Connect to domain disconnected message @@ -33,15 +32,17 @@ void ConnectionMonitor::init() { connect(&domainHandler, &DomainHandler::disconnectedFromDomain, this, &ConnectionMonitor::startTimer); connect(&domainHandler, &DomainHandler::connectedToDomain, this, &ConnectionMonitor::stopTimer); connect(&domainHandler, &DomainHandler::domainConnectionRefused, this, &ConnectionMonitor::stopTimer); + connect(&domainHandler, &DomainHandler::redirectToErrorDomainURL, this, &ConnectionMonitor::stopTimer); _timer.setSingleShot(true); if (!domainHandler.isConnected()) { _timer.start(ON_INITIAL_LOAD_REDIRECT_AFTER_DISCONNECTED_FOR_X_MS); } - connect(&_timer, &QTimer::timeout, this, []() { + connect(&_timer, &QTimer::timeout, this, [domainHandler]() { qDebug() << "ConnectionMonitor: Redirecting to 404 error domain"; - qApp->goToErrorDomainURL(REDIRECT_HIFI_ADDRESS); + // set in a timeout error + domainHandler.setErrorRedirectState(REDIRECT_HIFI_ADDRESS, 5); }); } diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index aa55fd2ebc..c217658c62 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -594,5 +594,5 @@ void WindowScriptingInterface::onMessageBoxSelected(int button) { float WindowScriptingInterface::domainLoadingProgress() { - return qApp->getDomainLoadingProgress(); + return qApp->getOctreePacketProcessor().domainLoadingProgress(); } diff --git a/libraries/networking/src/DomainHandler.cpp b/libraries/networking/src/DomainHandler.cpp index 4bed1646ee..59e3de922f 100644 --- a/libraries/networking/src/DomainHandler.cpp +++ b/libraries/networking/src/DomainHandler.cpp @@ -335,6 +335,12 @@ void DomainHandler::loadedErrorDomain(std::map namedPaths) { DependencyManager::get()->goToViewpointForPath(viewpoint, QString()); } +void DomainHandler::setRedirectErrorState(QUrl errorUrl, int reasonCode) { + _errorDomainURL = errorUrl; + _lastDomainConnectionError = reasonCode; + emit redirectToErrorDomainURL(_errorDomainURL); +} + void DomainHandler::requestDomainSettings() { qCDebug(networking) << "Requesting settings from domain server"; diff --git a/libraries/networking/src/DomainHandler.h b/libraries/networking/src/DomainHandler.h index 45c815eb5a..ab20936f43 100644 --- a/libraries/networking/src/DomainHandler.h +++ b/libraries/networking/src/DomainHandler.h @@ -87,6 +87,8 @@ public: void connectedToServerless(std::map namedPaths); void loadedErrorDomain(std::map namedPaths); + // sets domain handler in error state. + void setRedirectErrorState(QUrl errorUrl, int reasonCode); QString getViewPointFromNamedPath(QString namedPath); @@ -142,6 +144,11 @@ public: * 4 * The domain already has its maximum number of users. * + * + * TimedOut + * 5 + * Connecting to the domain timed out. + * * * * @typedef {number} Window.ConnectionRefusedReason @@ -151,7 +158,8 @@ public: ProtocolMismatch, LoginError, NotAuthorized, - TooManyUsers + TooManyUsers, + TimedOut }; public slots: @@ -188,7 +196,7 @@ signals: void settingsReceiveFail(); void domainConnectionRefused(QString reasonMessage, int reason, const QString& extraInfo); - void redirectToErrorDomainURL(QUrl errorDomaunURL); + void redirectToErrorDomainURL(QUrl errorDomainURL); void limitOfSilentDomainCheckInsReached();