mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 05:03:31 +02:00
provide session ID for metaverse heartbeat once received
This commit is contained in:
parent
0ea46cb415
commit
839c7fb8c2
3 changed files with 34 additions and 4 deletions
|
@ -31,6 +31,8 @@ DiscoverabilityManager::DiscoverabilityManager() :
|
||||||
|
|
||||||
const QString API_USER_LOCATION_PATH = "/api/v1/user/location";
|
const QString API_USER_LOCATION_PATH = "/api/v1/user/location";
|
||||||
|
|
||||||
|
const QString SESSION_ID_KEY = "session_id";
|
||||||
|
|
||||||
void DiscoverabilityManager::updateLocation() {
|
void DiscoverabilityManager::updateLocation() {
|
||||||
AccountManager& accountManager = AccountManager::getInstance();
|
AccountManager& accountManager = AccountManager::getInstance();
|
||||||
|
|
||||||
|
@ -86,7 +88,31 @@ void DiscoverabilityManager::updateLocation() {
|
||||||
} else if (UserActivityLogger::getInstance().isEnabled()) {
|
} else if (UserActivityLogger::getInstance().isEnabled()) {
|
||||||
// we still send a heartbeat to the metaverse server for stats collection
|
// we still send a heartbeat to the metaverse server for stats collection
|
||||||
const QString API_USER_HEARTBEAT_PATH = "/api/v1/user/heartbeat";
|
const QString API_USER_HEARTBEAT_PATH = "/api/v1/user/heartbeat";
|
||||||
accountManager.sendRequest(API_USER_HEARTBEAT_PATH, AccountManagerAuth::Required, QNetworkAccessManager::PutOperation);
|
|
||||||
|
JSONCallbackParameters callbackParameters;
|
||||||
|
callbackParameters.jsonCallbackReceiver = this;
|
||||||
|
callbackParameters.jsonCallbackMethod = "handleHeartbeatResponse";
|
||||||
|
|
||||||
|
QJsonObject heartbeatObject;
|
||||||
|
if (!_sessionID.isEmpty()) {
|
||||||
|
heartbeatObject[SESSION_ID_KEY] = _sessionID;
|
||||||
|
} else {
|
||||||
|
heartbeatObject[SESSION_ID_KEY] = QJsonValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
accountManager.sendRequest(API_USER_HEARTBEAT_PATH, AccountManagerAuth::Optional,
|
||||||
|
QNetworkAccessManager::PutOperation, callbackParameters,
|
||||||
|
QJsonDocument(heartbeatObject).toJson());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiscoverabilityManager::handleHeartbeatResponse(QNetworkReply& requestReply) {
|
||||||
|
QJsonObject jsonObject = QJsonDocument::fromJson(requestReply.readAll()).object();
|
||||||
|
|
||||||
|
static const QString STATUS_KEY = "status";
|
||||||
|
|
||||||
|
if (jsonObject.contains(STATUS_KEY) && jsonObject[STATUS_KEY] == "success") {
|
||||||
|
_sessionID = jsonObject[SESSION_ID_KEY].toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,10 +42,14 @@ public slots:
|
||||||
signals:
|
signals:
|
||||||
void discoverabilityModeChanged(Discoverability::Mode discoverabilityMode);
|
void discoverabilityModeChanged(Discoverability::Mode discoverabilityMode);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void handleHeartbeatResponse(QNetworkReply& requestReply);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DiscoverabilityManager();
|
DiscoverabilityManager();
|
||||||
|
|
||||||
Setting::Handle<int> _mode;
|
Setting::Handle<int> _mode;
|
||||||
|
QString _sessionID;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_DiscoverabilityManager_h
|
#endif // hifi_DiscoverabilityManager_h
|
|
@ -15,7 +15,7 @@
|
||||||
#include <QtCore/QUrl>
|
#include <QtCore/QUrl>
|
||||||
|
|
||||||
namespace NetworkingConstants {
|
namespace NetworkingConstants {
|
||||||
const QUrl METAVERSE_SERVER_URL = QUrl("https://metaverse.highfidelity.com");
|
const QUrl METAVERSE_SERVER_URL = QUrl("http://localhost:3000");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // hifi_NetworkingConstants_h
|
#endif // hifi_NetworkingConstants_h
|
Loading…
Reference in a new issue