History

send fallback socket, don't send HB if send usage disabled

Stephen Birarda committed 10 years ago

Commit 0ea46cb1 parent ec507442 files · +17 −4Browse files

Showing the changes to interface/src/DiscoverabilityManager.cpp (1 of 2 files). Show all

Unified · Split

interface/src/DiscoverabilityManager.cpp+15−4
@@ -15,6 +15,7 @@ · 14 unmodified lines
1515 #include <AddressManager.h>
1616 #include <DomainHandler.h>
1717 #include <NodeList.h>
18+#include <UserActivityLogger.h>
1819 #include <UUID.h>
1920
2021 #include "DiscoverabilityManager.h"
@@ -44,6 +45,7 @@ void DiscoverabilityManager::updateLocation() { · 23 unmodified lines
4445 QJsonObject rootObject;
4546
4647 QJsonObject locationObject;
48+
4749
4850 QString pathString = addressManager->currentPath();
4951
@@ -56,13 +58,22 @@ void DiscoverabilityManager::updateLocation() { · 6 unmodified lines
5658 const QString PLACE_ID_KEY_IN_LOCATION = "place_id";
5759 locationObject.insert(PLACE_ID_KEY_IN_LOCATION,
5860 uuidStringWithoutCurlyBraces(addressManager->getRootPlaceID()));
59−
60− } else {
61+ }
62+
63+ if (!domainHandler.getUUID().isNull()) {
6164 const QString DOMAIN_ID_KEY_IN_LOCATION = "domain_id";
6265 locationObject.insert(DOMAIN_ID_KEY_IN_LOCATION,
6366 uuidStringWithoutCurlyBraces(domainHandler.getUUID()));
6467 }
65−
68+
69+ // in case the place/domain isn't in the database, we send the network address and port
70+ auto& domainSockAddr = domainHandler.getSockAddr();
71+ const QString NETWORK_ADRESS_KEY_IN_LOCATION = "network_address";
72+ locationObject.insert(NETWORK_ADRESS_KEY_IN_LOCATION, domainSockAddr.getAddress().toString());
73+
74+ const QString NETWORK_ADDRESS_PORT_IN_LOCATION = "network_port";
75+ locationObject.insert(NETWORK_ADDRESS_PORT_IN_LOCATION, domainSockAddr.getPort());
76+
6677 const QString FRIENDS_ONLY_KEY_IN_LOCATION = "friends_only";
6778 locationObject.insert(FRIENDS_ONLY_KEY_IN_LOCATION, (_mode.get() == Discoverability::Friends));
6879
@@ -72,7 +83,7 @@ void DiscoverabilityManager::updateLocation() { · 3 unmodified lines
7283 QNetworkAccessManager::PutOperation,
7384 JSONCallbackParameters(), QJsonDocument(rootObject).toJson());
7485 }
75− } else {
86+ } else if (UserActivityLogger::getInstance().isEnabled()) {
7687 // we still send a heartbeat to the metaverse server for stats collection
7788 const QString API_USER_HEARTBEAT_PATH = "/api/v1/user/heartbeat";
7889 accountManager.sendRequest(API_USER_HEARTBEAT_PATH, AccountManagerAuth::Required, QNetworkAccessManager::PutOperation);