Showing the changes to libraries/networking/src/DomainHandler.cpp (1 of 5 files). Show all
Unified · Split
| @@ -227,6 +227,9 @@ void DomainHandler::setIsConnected(bool isConnected) { · 226 unmodified lines | ||
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | void DomainHandler::requestDomainSettings() { |
| 230 | + // TODO: the nodes basically lock if they don't get a response - add a timeout to this so that they at least restart | |
| 231 | + // if they can't get settings | |
| 232 | + | |
| 230 | 233 | NodeType_t owningNodeType = DependencyManager::get<NodeList>()->getOwnerType(); |
| 231 | 234 | if (owningNodeType == NodeType::Agent) { |
| 232 | 235 | // for now the agent nodes don't need any settings - this allows local assignment-clients |
| @@ -248,40 +251,6 @@ void DomainHandler::requestDomainSettings() { · 15 unmodified lines | ||
| 248 | 251 | } |
| 249 | 252 | } |
| 250 | 253 | |
| 251 | −const int MAX_SETTINGS_REQUEST_FAILED_ATTEMPTS = 5; | |
| 252 | − | |
| 253 | −void DomainHandler::settingsRequestFinished() { | |
| 254 | − QNetworkReply* settingsReply = reinterpret_cast<QNetworkReply*>(sender()); | |
| 255 | − | |
| 256 | − int replyCode = settingsReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); | |
| 257 | − | |
| 258 | − if (settingsReply->error() == QNetworkReply::NoError && replyCode != 301 && replyCode != 302) { | |
| 259 | − // parse the JSON to a QJsonObject and save it | |
| 260 | − _settingsObject = QJsonDocument::fromJson(settingsReply->readAll()).object(); | |
| 261 | − | |
| 262 | − qCDebug(networking) << "Received domain settings."; | |
| 263 | − emit settingsReceived(_settingsObject); | |
| 264 | − | |
| 265 | − // reset failed settings requests to 0, we got them | |
| 266 | − _failedSettingsRequests = 0; | |
| 267 | − } else { | |
| 268 | − // error grabbing the settings - in some cases this means we are stuck | |
| 269 | − // so we should retry until we get it | |
| 270 | − qCDebug(networking) << "Error getting domain settings -" << settingsReply->errorString() << "- retrying"; | |
| 271 | − | |
| 272 | − if (++_failedSettingsRequests >= MAX_SETTINGS_REQUEST_FAILED_ATTEMPTS) { | |
| 273 | − qCDebug(networking) << "Failed to retreive domain-server settings" << MAX_SETTINGS_REQUEST_FAILED_ATTEMPTS | |
| 274 | − << "times. Re-setting connection to domain."; | |
| 275 | − clearSettings(); | |
| 276 | − clearConnectionInfo(); | |
| 277 | − emit settingsReceiveFail(); | |
| 278 | − } else { | |
| 279 | − requestDomainSettings(); | |
| 280 | − } | |
| 281 | − } | |
| 282 | − settingsReply->deleteLater(); | |
| 283 | −} | |
| 284 | − | |
| 285 | 254 | void DomainHandler::processSettingsPacketList(QSharedPointer<NLPacketList> packetList) { |
| 286 | 255 | auto data = packetList->getMessage(); |
| 287 | 256 | |