Only mark a PC offline if server info failed after 3 straight tries

This commit is contained in:
Cameron Gutman 2015-11-11 18:14:04 -08:00
parent 814470f4bf
commit b495246f34

View File

@ -87,6 +87,8 @@ static const float POLL_RATE = 2.0f; // Poll every 2 seconds
Log(LOG_D, @"%@ has %d unique addresses", _host.name, [addresses count]); Log(LOG_D, @"%@ has %d unique addresses", _host.name, [addresses count]);
// Give the PC 3 tries to respond before declaring it offline
for (int i = 0; i < 3; i++) {
for (NSString *address in addresses) { for (NSString *address in addresses) {
if (self.cancelled) { if (self.cancelled) {
// Get out without updating the status because // Get out without updating the status because
@ -103,6 +105,16 @@ static const float POLL_RATE = 2.0f; // Poll every 2 seconds
} }
} }
if (receivedResponse) {
Log(LOG_I, @"Received serverinfo response on try %d", i);
break;
}
else {
// Wait for one second then retry
[NSThread sleepForTimeInterval:1];
}
}
_host.online = receivedResponse; _host.online = receivedResponse;
if (receivedResponse) { if (receivedResponse) {
Log(LOG_D, @"Received response from: %@\n{\n\t address:%@ \n\t localAddress:%@ \n\t externalAddress:%@ \n\t uuid:%@ \n\t mac:%@ \n\t pairState:%d \n\t online:%d \n\t activeAddress:%@ \n}", _host.name, _host.address, _host.localAddress, _host.externalAddress, _host.uuid, _host.mac, _host.pairState, _host.online, _host.activeAddress); Log(LOG_D, @"Received response from: %@\n{\n\t address:%@ \n\t localAddress:%@ \n\t externalAddress:%@ \n\t uuid:%@ \n\t mac:%@ \n\t pairState:%d \n\t online:%d \n\t activeAddress:%@ \n}", _host.name, _host.address, _host.localAddress, _host.externalAddress, _host.uuid, _host.mac, _host.pairState, _host.online, _host.activeAddress);