History

add TODO for settings fail, cleanup

Stephen Birarda committed 11 years ago

Commit f7799bc1 parent e84595a5 files · +7 −37Browse files

Showing the changes to libraries/networking/src/DomainHandler.cpp (1 of 5 files). Show all

Unified · Split

libraries/networking/src/DomainHandler.cpp+3−34
@@ -227,6 +227,9 @@ void DomainHandler::setIsConnected(bool isConnected) { · 226 unmodified lines
227227 }
228228
229229 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+
230233 NodeType_t owningNodeType = DependencyManager::get<NodeList>()->getOwnerType();
231234 if (owningNodeType == NodeType::Agent) {
232235 // 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
248251 }
249252 }
250253
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−
285254 void DomainHandler::processSettingsPacketList(QSharedPointer<NLPacketList> packetList) {
286255 auto data = packetList->getMessage();
287256