Merge branch '404DomainRedirect' of https://github.com/wayne-chen/hifi into 404DomainRedirect

This commit is contained in:
Wayne Chen 2018-08-30 19:55:51 -07:00
commit e3f5f4c55a
5 changed files with 29 additions and 29 deletions

View file

@ -1197,11 +1197,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
getOverlays().deleteOverlay(getTabletHomeButtonID());
getOverlays().deleteOverlay(getTabletFrameID());
});
#if defined(Q_OS_ANDROID)
connect(&domainHandler, &DomainHandler::domainConnectionRefused, this, &Application::domainConnectionRefused);
#else
connect(&domainHandler, &DomainHandler::domainConnectionRefused, this, &Application::domainConnectionRedirect);
#endif
&domainHandler.setErrorDomainURL(QUrl(REDIRECT_HIFI_ADDRESS));
// We could clear ATP assets only when changing domains, but it's possible that the domain you are connected
// to has gone down and switched to a new content set, so when you reconnect the cached ATP assets will no longer be valid.
@ -2345,31 +2343,11 @@ void Application::domainConnectionRefused(const QString& reasonMessage, int reas
}
}
void Application::domainConnectionRedirect(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) {
DomainHandler::ConnectionRefusedReason reasonCode = static_cast<DomainHandler::ConnectionRefusedReason>(reasonCodeInt);
void Application::domainConnectionRedirect() {
auto addressManager = DependencyManager::get<AddressManager>();
if (reasonCode == DomainHandler::ConnectionRefusedReason::TooManyUsers && !extraInfo.isEmpty()) {
addressManager->handleLookupString(extraInfo);
return;
}
switch (reasonCode) {
case DomainHandler::ConnectionRefusedReason::ProtocolMismatch:
case DomainHandler::ConnectionRefusedReason::TooManyUsers:
case DomainHandler::ConnectionRefusedReason::Unknown: {
QString message = "Unable to connect to the location you are visiting.\n";
message += reasonMessage;
//OffscreenUi::asyncWarning("", message);
addressManager->handleLookupString(REDIRECT_HIFI_ADDRESS);
getMyAvatar()->setWorldVelocity(glm::vec3(0.0f));
// in (w, x, y, z) component-structure for the constructor
break;
}
default:
// nothing to do.
break;
}
addressManager->handleLookupString(REDIRECT_HIFI_ADDRESS);
getMyAvatar()->setWorldVelocity(glm::vec3(0.0f));
}

View file

@ -474,7 +474,7 @@ private slots:
void updateDisplayMode();
void setDisplayPlugin(DisplayPluginPointer newPlugin);
void domainConnectionRefused(const QString& reasonMessage, int reason, const QString& extraInfo);
void domainConnectionRedirect(const QString& reasonMessage, int reason, const QString& extraInfo);
void domainConnectionRedirect();
void addAssetToWorldCheckModelSize();

View file

@ -319,7 +319,9 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
// lookupUrl.scheme() == URL_SCHEME_HTTPS ||
_previousLookup.clear();
_shareablePlaceName.clear();
setDomainInfo(lookupUrl, trigger);
if (lookupUrl.toString() != REDIRECT_HIFI_ADDRESS) {
setDomainInfo(lookupUrl, trigger);
}
emit lookupResultsFinished();
QString path = DOMAIN_SPAWNING_POINT;

View file

@ -128,6 +128,10 @@ void DomainHandler::hardReset() {
_pendingPath.clear();
}
void DomainHandler::setErrorDomainURL(const QUrl& url) {
return;
}
void DomainHandler::setSockAddr(const HifiSockAddr& sockAddr, const QString& hostname) {
if (_sockAddr != sockAddr) {
// we should reset on a sockAddr change
@ -451,7 +455,17 @@ void DomainHandler::processDomainServerConnectionDeniedPacket(QSharedPointer<Rec
if (!_domainConnectionRefusals.contains(reasonMessage)) {
_domainConnectionRefusals.insert(reasonMessage);
#if defined(Q_OS_ANDROID)
emit domainConnectionRefused(reasonMessage, (int)reasonCode, extraInfo);
#else
if (reasonCode == ConnectionRefusedReason::ProtocolMismatch || reasonCode == ConnectionRefusedReason::NotAuthorized) {
_isInErrorState = true;
// ingest the error - this is a "hard" connection refusal.
emit domainURLChanged(_errorDomainURL);
} else {
emit domainConnectionRefused(reasonMessage, (int)reasonCode, extraInfo);
}
#endif
}
auto accountManager = DependencyManager::get<AccountManager>();

View file

@ -50,6 +50,9 @@ public:
QString getHostname() const { return _domainURL.host(); }
QUrl getErrorDomainURL(){ return _errorDomainURL; }
void setErrorDomainURL(const QUrl& url);
const QHostAddress& getIP() const { return _sockAddr.getAddress(); }
void setIPToLocalhost() { _sockAddr.setAddress(QHostAddress(QHostAddress::LocalHost)); }
@ -179,6 +182,7 @@ signals:
void settingsReceiveFail();
void domainConnectionRefused(QString reasonMessage, int reason, const QString& extraInfo);
void redirectToErrorDomainURL();
void limitOfSilentDomainCheckInsReached();
@ -190,6 +194,7 @@ private:
QUuid _uuid;
Node::LocalID _localID;
QUrl _domainURL;
QUrl _errorDomainURL;
HifiSockAddr _sockAddr;
QUuid _assignmentUUID;
QUuid _connectionToken;
@ -198,6 +203,7 @@ private:
HifiSockAddr _iceServerSockAddr;
NetworkPeer _icePeer;
bool _isConnected { false };
bool _isInErrorState { false };
QJsonObject _settingsObject;
QString _pendingPath;
QTimer _settingsTimer;