Showing the changes to interface/src/DiscoverabilityManager.cpp (1 of 2 files). Show all
Unified · Split
| @@ -30,6 +30,7 @@ DiscoverabilityManager::DiscoverabilityManager() : · 29 unmodified lines | |||
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | const QString API_USER_LOCATION_PATH = "/api/v1/user/location"; | 32 | const QString API_USER_LOCATION_PATH = "/api/v1/user/location"; |
| 33 | const QString API_USER_HEARTBEAT_PATH = "/api/v1/user/heartbeat"; | ||
| 33 | 34 | ||
| 34 | const QString SESSION_ID_KEY = "session_id"; | 35 | const QString SESSION_ID_KEY = "session_id"; |
| 35 | 36 | ||
| @@ -48,7 +49,6 @@ void DiscoverabilityManager::updateLocation() { · 12 unmodified lines | |||
| 48 | 49 | ||
| 49 | QJsonObject locationObject; | 50 | QJsonObject locationObject; |
| 50 | 51 | ||
| 51 | |||
| 52 | QString pathString = addressManager->currentPath(); | 52 | QString pathString = addressManager->currentPath(); |
| 53 | 53 | ||
| 54 | const QString LOCATION_KEY_IN_ROOT = "location"; | 54 | const QString LOCATION_KEY_IN_ROOT = "location"; |
| @@ -78,16 +78,33 @@ void DiscoverabilityManager::updateLocation() { · 23 unmodified lines | |||
| 78 | 78 | ||
| 79 | const QString FRIENDS_ONLY_KEY_IN_LOCATION = "friends_only"; | 79 | const QString FRIENDS_ONLY_KEY_IN_LOCATION = "friends_only"; |
| 80 | locationObject.insert(FRIENDS_ONLY_KEY_IN_LOCATION, (_mode.get() == Discoverability::Friends)); | 80 | locationObject.insert(FRIENDS_ONLY_KEY_IN_LOCATION, (_mode.get() == Discoverability::Friends)); |
| 81 | 81 | ||
| 82 | rootObject.insert(LOCATION_KEY_IN_ROOT, locationObject); | 82 | // if we have a session ID add it now, otherwise add a null value |
| 83 | 83 | rootObject[SESSION_ID_KEY] = _sessionID.isEmpty() ? QJsonValue() : _sessionID; | |
| 84 | accountManager.sendRequest(API_USER_LOCATION_PATH, AccountManagerAuth::Required, | 84 | |
| 85 | JSONCallbackParameters callbackParameters; | ||
| 86 | callbackParameters.jsonCallbackReceiver = this; | ||
| 87 | callbackParameters.jsonCallbackMethod = "handleHeartbeatResponse"; | ||
| 88 | |||
| 89 | // figure out if we'll send a fresh location or just a simple heartbeat | ||
| 90 | auto apiPath = API_USER_HEARTBEAT_PATH; | ||
| 91 | |||
| 92 | if (locationObject != _lastLocationObject) { | ||
| 93 | // we have a changed location, send it now | ||
| 94 | _lastLocationObject = locationObject; | ||
| 95 | |||
| 96 | rootObject.insert(LOCATION_KEY_IN_ROOT, locationObject); | ||
| 97 | |||
| 98 | apiPath = API_USER_LOCATION_PATH; | ||
| 99 | } | ||
| 100 | |||
| 101 | accountManager.sendRequest(apiPath, AccountManagerAuth::Required, | ||
| 85 | QNetworkAccessManager::PutOperation, | 102 | QNetworkAccessManager::PutOperation, |
| 86 | JSONCallbackParameters(), QJsonDocument(rootObject).toJson()); | 103 | callbackParameters, QJsonDocument(rootObject).toJson()); |
| 104 | |||
| 87 | } | 105 | } |
| 88 | } else if (UserActivityLogger::getInstance().isEnabled()) { | 106 | } else if (UserActivityLogger::getInstance().isEnabled()) { |
| 89 | // we still send a heartbeat to the metaverse server for stats collection | 107 | // we still send a heartbeat to the metaverse server for stats collection |
| 90 | const QString API_USER_HEARTBEAT_PATH = "/api/v1/user/heartbeat"; | ||
| 91 | 108 | ||
| 92 | JSONCallbackParameters callbackParameters; | 109 | JSONCallbackParameters callbackParameters; |
| 93 | callbackParameters.jsonCallbackReceiver = this; | 110 | callbackParameters.jsonCallbackReceiver = this; |