mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2025-07-27 06:32:59 +00:00
fixed host online state and simplified some code
This commit is contained in:
parent
879f304a79
commit
337e5e3d9d
@ -48,6 +48,7 @@
|
||||
DataManager* dataMan = [[DataManager alloc] init];
|
||||
host = [dataMan createHost];
|
||||
host.address = hostAddress;
|
||||
host.online = YES;
|
||||
[serverInfoResponse populateHost:host];
|
||||
if (![self addHostToDiscovery:host]) {
|
||||
[dataMan removeHost:host];
|
||||
|
@ -77,9 +77,6 @@ static const float POLL_RATE = 2.0f; // Poll every 2 seconds
|
||||
_host.online = receivedResponse;
|
||||
if (receivedResponse) {
|
||||
NSLog(@"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}", _host.name, _host.address, _host.localAddress, _host.externalAddress, _host.uuid, _host.mac, _host.pairState, _host.online);
|
||||
} else {
|
||||
// If the host is not online, we do not know the pairstate
|
||||
_host.pairState = PairStateUnknown;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,30 +25,17 @@ static NSString* TAG_PAIR_STATUS = @"PairStatus";
|
||||
}
|
||||
|
||||
- (void) populateHost:(Host*)host {
|
||||
NSString* hostname = [self getStringTag:TAG_HOSTNAME];
|
||||
NSString* externalIp = [self getStringTag:TAG_EXTERNAL_IP];
|
||||
NSString* localIp = [self getStringTag:TAG_LOCAL_IP];
|
||||
NSString* uniqueId = [self getStringTag:TAG_UNIQUE_ID];
|
||||
NSString* macAddress = [self getStringTag:TAG_MAC_ADDRESS];
|
||||
NSString* pairStatus = [self getStringTag:TAG_PAIR_STATUS];
|
||||
host.name = [self getStringTag:TAG_HOSTNAME];
|
||||
host.externalAddress = [self getStringTag:TAG_EXTERNAL_IP];
|
||||
host.localAddress = [self getStringTag:TAG_LOCAL_IP];
|
||||
host.uuid = [self getStringTag:TAG_UNIQUE_ID];
|
||||
host.mac = [self getStringTag:TAG_MAC_ADDRESS];
|
||||
|
||||
if (hostname) {
|
||||
host.name = hostname;
|
||||
}
|
||||
if (externalIp) {
|
||||
host.externalAddress = externalIp;
|
||||
}
|
||||
if (localIp) {
|
||||
host.localAddress = localIp;
|
||||
}
|
||||
if (uniqueId) {
|
||||
host.uuid = uniqueId;
|
||||
}
|
||||
if (macAddress) {
|
||||
host.mac = macAddress;
|
||||
}
|
||||
if (pairStatus) {
|
||||
host.pairState = [pairStatus isEqualToString:@"1"] ? PairStatePaired : PairStateUnpaired;
|
||||
NSInteger pairStatus;
|
||||
if ([self getIntTag:TAG_PAIR_STATUS value:&pairStatus]) {
|
||||
host.pairState = pairStatus ? PairStatePaired : PairStateUnpaired;
|
||||
} else {
|
||||
host.pairState = PairStateUnknown;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user