mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 18:15:10 +02:00
only force a new temp name if already a temp domain-server
This commit is contained in:
parent
ba49fd2c61
commit
f3e30221f0
1 changed files with 33 additions and 30 deletions
|
@ -1168,42 +1168,45 @@ void DomainServer::handleMetaverseHeartbeatError(QNetworkReply& requestReply) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if we need to force a new temporary domain name
|
// only attempt to grab a new temporary name if we're already a temporary domain server
|
||||||
switch (requestReply.error()) {
|
if (_type == MetaverseTemporaryDomain) {
|
||||||
// if we have a temporary domain with a bad token, we get a 401
|
// check if we need to force a new temporary domain name
|
||||||
case QNetworkReply::NetworkError::AuthenticationRequiredError: {
|
switch (requestReply.error()) {
|
||||||
static const QString DATA_KEY = "data";
|
// if we have a temporary domain with a bad token, we get a 401
|
||||||
static const QString TOKEN_KEY = "api_key";
|
case QNetworkReply::NetworkError::AuthenticationRequiredError: {
|
||||||
|
static const QString DATA_KEY = "data";
|
||||||
|
static const QString TOKEN_KEY = "api_key";
|
||||||
|
|
||||||
QJsonObject jsonObject = QJsonDocument::fromJson(requestReply.readAll()).object();
|
QJsonObject jsonObject = QJsonDocument::fromJson(requestReply.readAll()).object();
|
||||||
auto tokenFailure = jsonObject[DATA_KEY].toObject()[TOKEN_KEY];
|
auto tokenFailure = jsonObject[DATA_KEY].toObject()[TOKEN_KEY];
|
||||||
|
|
||||||
if (!tokenFailure.isNull()) {
|
if (!tokenFailure.isNull()) {
|
||||||
qWarning() << "Temporary domain name lacks a valid API key, and is being reset.";
|
qWarning() << "Temporary domain name lacks a valid API key, and is being reset.";
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
// if the domain does not (or no longer) exists, we get a 404
|
||||||
|
case QNetworkReply::NetworkError::ContentNotFoundError:
|
||||||
|
qWarning() << "Domain not found, getting a new temporary domain.";
|
||||||
|
break;
|
||||||
|
// otherwise, we erred on something else, and should not force a temporary domain
|
||||||
|
default:
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
// if the domain does not (or no longer) exists, we get a 404
|
|
||||||
case QNetworkReply::NetworkError::ContentNotFoundError:
|
|
||||||
qWarning() << "Domain not found, getting a new temporary domain.";
|
|
||||||
break;
|
|
||||||
// otherwise, we erred on something else, and should not force a temporary domain
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// halt heartbeats until we have a token
|
// halt heartbeats until we have a token
|
||||||
_metaverseHeartbeatTimer->deleteLater();
|
_metaverseHeartbeatTimer->deleteLater();
|
||||||
_metaverseHeartbeatTimer = nullptr;
|
_metaverseHeartbeatTimer = nullptr;
|
||||||
|
|
||||||
// give up eventually to avoid flooding traffic
|
// give up eventually to avoid flooding traffic
|
||||||
static const int MAX_ATTEMPTS = 5;
|
static const int MAX_ATTEMPTS = 5;
|
||||||
static int attempt = 0;
|
static int attempt = 0;
|
||||||
if (++attempt < MAX_ATTEMPTS) {
|
if (++attempt < MAX_ATTEMPTS) {
|
||||||
// get a new temporary name and token
|
// get a new temporary name and token
|
||||||
getTemporaryName(true);
|
getTemporaryName(true);
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "Already attempted too many temporary domain requests. Please set a domain ID manually or restart.";
|
qWarning() << "Already attempted too many temporary domain requests. Please set a domain ID manually or restart.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue