mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 15:38:00 +02:00
complete handling of immediate temp name grab
This commit is contained in:
parent
858adf383e
commit
4cbbd24c7e
7 changed files with 70 additions and 22 deletions
|
@ -242,16 +242,49 @@ void DomainServer::optionallyGetTemporaryName(const QStringList& arguments) {
|
||||||
callbackParameters.errorCallbackMethod = "handleTempDomainError";
|
callbackParameters.errorCallbackMethod = "handleTempDomainError";
|
||||||
|
|
||||||
accountManager.sendRequest("/api/v1/domains/temporary", AccountManagerAuth::None,
|
accountManager.sendRequest("/api/v1/domains/temporary", AccountManagerAuth::None,
|
||||||
QNetworkAccessManager::GetOperation, callbackParameters);
|
QNetworkAccessManager::PostOperation, callbackParameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainServer::handleTempDomainSuccess(QNetworkReply& requestReply) {
|
void DomainServer::handleTempDomainSuccess(QNetworkReply& requestReply) {
|
||||||
QJsonObject jsonObject = QJsonDocument::fromJson(requestReply.readAll()).object();
|
QJsonObject jsonObject = QJsonDocument::fromJson(requestReply.readAll()).object();
|
||||||
|
|
||||||
|
// grab the information for the new domain
|
||||||
|
static const QString DATA_KEY = "data";
|
||||||
|
static const QString DOMAIN_KEY = "domain";
|
||||||
|
static const QString ID_KEY = "id";
|
||||||
|
static const QString NAME_KEY = "name";
|
||||||
|
|
||||||
|
auto domainObject = jsonObject[DATA_KEY].toObject()[DOMAIN_KEY].toObject();
|
||||||
|
if (!domainObject.isEmpty()) {
|
||||||
|
auto id = domainObject[ID_KEY].toString();
|
||||||
|
auto name = domainObject[NAME_KEY].toString();
|
||||||
|
|
||||||
|
qInfo() << "Received new temporary domain name" << name;
|
||||||
|
qDebug() << "The temporary domain ID is" << id;
|
||||||
|
|
||||||
|
// store the new domain ID and auto network setting immediately
|
||||||
|
QString newSettingsJSON = QString("{\"metaverse\": { \"id\": \"%1\", \"automatic_networking\": \"full\"}}").arg(id);
|
||||||
|
auto settingsDocument = QJsonDocument::fromJson(newSettingsJSON.toUtf8());
|
||||||
|
_settingsManager.recurseJSONObjectAndOverwriteSettings(settingsDocument.object());
|
||||||
|
|
||||||
|
// store the new ID and auto networking setting on disk
|
||||||
|
_settingsManager.persistToFile();
|
||||||
|
|
||||||
|
// change our domain ID immediately
|
||||||
|
DependencyManager::get<LimitedNodeList>()->setSessionUUID(QUuid { id });
|
||||||
|
|
||||||
|
// change our automatic networking settings so that we're communicating with the ICE server
|
||||||
|
setupICEHeartbeatForFullNetworking();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
qWarning() << "There were problems parsing the API response containing a temporary domain name. Please try again"
|
||||||
|
<< "via domain-server relaunch or from the domain-server settings.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainServer::handleTempDomainError(QNetworkReply& requestReply) {
|
void DomainServer::handleTempDomainError(QNetworkReply& requestReply) {
|
||||||
qWarning() << "A temporary name was requested but there was an error creating one. Try again via domain-server relaunch"
|
qWarning() << "A temporary name was requested but there was an error creating one. Please try again via domain-server relaunch"
|
||||||
<< "or from the domain-server settings.";
|
<< "or from the domain-server settings.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,19 +450,7 @@ void DomainServer::setupAutomaticNetworking() {
|
||||||
_settingsManager.valueOrDefaultValueForKeyPath(METAVERSE_AUTOMATIC_NETWORKING_KEY_PATH).toString();
|
_settingsManager.valueOrDefaultValueForKeyPath(METAVERSE_AUTOMATIC_NETWORKING_KEY_PATH).toString();
|
||||||
|
|
||||||
if (_automaticNetworkingSetting == FULL_AUTOMATIC_NETWORKING_VALUE) {
|
if (_automaticNetworkingSetting == FULL_AUTOMATIC_NETWORKING_VALUE) {
|
||||||
// call our sendHeartbeatToIceServer immediately anytime a local or public socket changes
|
|
||||||
connect(nodeList.data(), &LimitedNodeList::localSockAddrChanged,
|
|
||||||
this, &DomainServer::sendHeartbeatToIceServer);
|
|
||||||
connect(nodeList.data(), &LimitedNodeList::publicSockAddrChanged,
|
|
||||||
this, &DomainServer::sendHeartbeatToIceServer);
|
|
||||||
|
|
||||||
// we need this DS to know what our public IP is - start trying to figure that out now
|
|
||||||
nodeList->startSTUNPublicSocketUpdate();
|
|
||||||
|
|
||||||
// setup a timer to heartbeat with the ice-server every so often
|
|
||||||
QTimer* iceHeartbeatTimer = new QTimer(this);
|
|
||||||
connect(iceHeartbeatTimer, &QTimer::timeout, this, &DomainServer::sendHeartbeatToIceServer);
|
|
||||||
iceHeartbeatTimer->start(ICE_HEARBEAT_INTERVAL_MSECS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!didSetupAccountManagerWithAccessToken()) {
|
if (!didSetupAccountManagerWithAccessToken()) {
|
||||||
|
@ -479,6 +500,26 @@ void DomainServer::setupAutomaticNetworking() {
|
||||||
dataHeartbeatTimer->start(DOMAIN_SERVER_DATA_WEB_HEARTBEAT_MSECS);
|
dataHeartbeatTimer->start(DOMAIN_SERVER_DATA_WEB_HEARTBEAT_MSECS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DomainServer::setupICEHeartbeatForFullNetworking() {
|
||||||
|
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
|
|
||||||
|
// call our sendHeartbeatToIceServer immediately anytime a local or public socket changes
|
||||||
|
connect(limitedNodeList.data(), &LimitedNodeList::localSockAddrChanged,
|
||||||
|
this, &DomainServer::sendHeartbeatToIceServer);
|
||||||
|
connect(limitedNodeList.data(), &LimitedNodeList::publicSockAddrChanged,
|
||||||
|
this, &DomainServer::sendHeartbeatToIceServer);
|
||||||
|
|
||||||
|
// we need this DS to know what our public IP is - start trying to figure that out now
|
||||||
|
limitedNodeList->startSTUNPublicSocketUpdate();
|
||||||
|
|
||||||
|
if (!_iceHeartbeatTimer) {
|
||||||
|
// setup a timer to heartbeat with the ice-server every so often
|
||||||
|
_iceHeartbeatTimer = new QTimer { this };
|
||||||
|
connect(_iceHeartbeatTimer, &QTimer::timeout, this, &DomainServer::sendHeartbeatToIceServer);
|
||||||
|
_iceHeartbeatTimer->start(ICE_HEARBEAT_INTERVAL_MSECS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DomainServer::loginFailed() {
|
void DomainServer::loginFailed() {
|
||||||
qDebug() << "Login to data server has failed. domain-server will now quit";
|
qDebug() << "Login to data server has failed. domain-server will now quit";
|
||||||
QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection);
|
||||||
|
|
|
@ -90,6 +90,7 @@ private:
|
||||||
bool resetAccountManagerAccessToken();
|
bool resetAccountManagerAccessToken();
|
||||||
|
|
||||||
void setupAutomaticNetworking();
|
void setupAutomaticNetworking();
|
||||||
|
void setupICEHeartbeatForFullNetworking();
|
||||||
void sendHeartbeatToDataServer(const QString& networkAddress);
|
void sendHeartbeatToDataServer(const QString& networkAddress);
|
||||||
|
|
||||||
unsigned int countConnectedUsers();
|
unsigned int countConnectedUsers();
|
||||||
|
@ -149,6 +150,8 @@ private:
|
||||||
DomainServerSettingsManager _settingsManager;
|
DomainServerSettingsManager _settingsManager;
|
||||||
|
|
||||||
HifiSockAddr _iceServerSocket;
|
HifiSockAddr _iceServerSocket;
|
||||||
|
|
||||||
|
QTimer* _iceHeartbeatTimer { nullptr }; // this looks like it dangles when created but it's parented to the DomainServer
|
||||||
|
|
||||||
friend class DomainGatekeeper;
|
friend class DomainGatekeeper;
|
||||||
};
|
};
|
||||||
|
|
|
@ -193,7 +193,7 @@ bool DomainServerSettingsManager::handleAuthenticatedHTTPRequest(HTTPConnection
|
||||||
qDebug() << "DomainServerSettingsManager postedObject -" << postedObject;
|
qDebug() << "DomainServerSettingsManager postedObject -" << postedObject;
|
||||||
|
|
||||||
// we recurse one level deep below each group for the appropriate setting
|
// we recurse one level deep below each group for the appropriate setting
|
||||||
recurseJSONObjectAndOverwriteSettings(postedObject, _configMap.getUserConfig());
|
recurseJSONObjectAndOverwriteSettings(postedObject);
|
||||||
|
|
||||||
// store whatever the current _settingsMap is to file
|
// store whatever the current _settingsMap is to file
|
||||||
persistToFile();
|
persistToFile();
|
||||||
|
@ -407,8 +407,9 @@ QJsonObject DomainServerSettingsManager::settingDescriptionFromGroup(const QJson
|
||||||
return QJsonObject();
|
return QJsonObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJsonObject& postedObject,
|
void DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJsonObject& postedObject) {
|
||||||
QVariantMap& settingsVariant) {
|
auto& settingsVariant = _configMap.getUserConfig();
|
||||||
|
|
||||||
// Iterate on the setting groups
|
// Iterate on the setting groups
|
||||||
foreach(const QString& rootKey, postedObject.keys()) {
|
foreach(const QString& rootKey, postedObject.keys()) {
|
||||||
QJsonValue rootValue = postedObject[rootKey];
|
QJsonValue rootValue = postedObject[rootKey];
|
||||||
|
|
|
@ -46,7 +46,7 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QJsonObject responseObjectForType(const QString& typeValue, bool isAuthenticated = false);
|
QJsonObject responseObjectForType(const QString& typeValue, bool isAuthenticated = false);
|
||||||
void recurseJSONObjectAndOverwriteSettings(const QJsonObject& postedObject, QVariantMap& settingsVariant);
|
void recurseJSONObjectAndOverwriteSettings(const QJsonObject& postedObject);
|
||||||
|
|
||||||
void updateSetting(const QString& key, const QJsonValue& newValue, QVariantMap& settingMap,
|
void updateSetting(const QString& key, const QJsonValue& newValue, QVariantMap& settingMap,
|
||||||
const QJsonObject& settingDescription);
|
const QJsonObject& settingDescription);
|
||||||
|
@ -56,6 +56,8 @@ private:
|
||||||
double _descriptionVersion;
|
double _descriptionVersion;
|
||||||
QJsonArray _descriptionArray;
|
QJsonArray _descriptionArray;
|
||||||
HifiConfigVariantMap _configMap;
|
HifiConfigVariantMap _configMap;
|
||||||
|
|
||||||
|
friend class DomainServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_DomainServerSettingsManager_h
|
#endif // hifi_DomainServerSettingsManager_h
|
||||||
|
|
|
@ -788,8 +788,6 @@ void LimitedNodeList::processSTUNResponse(std::unique_ptr<udt::BasePacket> packe
|
||||||
}
|
}
|
||||||
|
|
||||||
void LimitedNodeList::startSTUNPublicSocketUpdate() {
|
void LimitedNodeList::startSTUNPublicSocketUpdate() {
|
||||||
assert(!_initialSTUNTimer);
|
|
||||||
|
|
||||||
if (!_initialSTUNTimer) {
|
if (!_initialSTUNTimer) {
|
||||||
// if we don't know the STUN IP yet we need to have ourselves be called once it is known
|
// if we don't know the STUN IP yet we need to have ourselves be called once it is known
|
||||||
if (_stunSockAddr.getAddress().isNull()) {
|
if (_stunSockAddr.getAddress().isNull()) {
|
||||||
|
|
|
@ -42,6 +42,8 @@ LogHandler::LogHandler() :
|
||||||
|
|
||||||
const char* stringForLogType(LogMsgType msgType) {
|
const char* stringForLogType(LogMsgType msgType) {
|
||||||
switch (msgType) {
|
switch (msgType) {
|
||||||
|
case LogInfo:
|
||||||
|
return "INFO";
|
||||||
case LogDebug:
|
case LogDebug:
|
||||||
return "DEBUG";
|
return "DEBUG";
|
||||||
case LogWarning:
|
case LogWarning:
|
||||||
|
|
|
@ -22,11 +22,12 @@
|
||||||
const int VERBOSE_LOG_INTERVAL_SECONDS = 5;
|
const int VERBOSE_LOG_INTERVAL_SECONDS = 5;
|
||||||
|
|
||||||
enum LogMsgType {
|
enum LogMsgType {
|
||||||
|
LogInfo = QtInfoMsg,
|
||||||
LogDebug = QtDebugMsg,
|
LogDebug = QtDebugMsg,
|
||||||
LogWarning = QtWarningMsg,
|
LogWarning = QtWarningMsg,
|
||||||
LogCritical = QtCriticalMsg,
|
LogCritical = QtCriticalMsg,
|
||||||
LogFatal = QtFatalMsg,
|
LogFatal = QtFatalMsg,
|
||||||
LogSuppressed
|
LogSuppressed = 100
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Handles custom message handling and sending of stats/logs to Logstash instance
|
/// Handles custom message handling and sending of stats/logs to Logstash instance
|
||||||
|
|
Loading…
Reference in a new issue