mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 06:01:12 +00:00
now parse server info into host object all at once
This commit is contained in:
@@ -45,7 +45,7 @@ static const float POLL_RATE = 2.0f; // Poll every 2 seconds
|
||||
HttpManager* hMan = [[HttpManager alloc] initWithHost:_host.localAddress uniqueId:_uniqueId deviceName:deviceName cert:_cert];
|
||||
NSData* serverInfoData = [hMan executeRequestSynchronously:[hMan newServerInfoRequest]];
|
||||
if ([[HttpManager getStatusStringFromXML:serverInfoData] isEqualToString:@"OK"]) {
|
||||
[DiscoveryWorker updateHost:_host withServerInfo:serverInfoData];
|
||||
[HttpManager populateHostFromXML:serverInfoData host:_host];
|
||||
_host.address = _host.localAddress;
|
||||
receivedResponse = YES;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ static const float POLL_RATE = 2.0f; // Poll every 2 seconds
|
||||
HttpManager* hMan = [[HttpManager alloc] initWithHost:_host.externalAddress uniqueId:_uniqueId deviceName:deviceName cert:_cert];
|
||||
NSData* serverInfoData = [hMan executeRequestSynchronously:[hMan newServerInfoRequest]];
|
||||
if ([[HttpManager getStatusStringFromXML:serverInfoData] isEqualToString:@"OK"]) {
|
||||
[DiscoveryWorker updateHost:_host withServerInfo:serverInfoData];
|
||||
[HttpManager populateHostFromXML:serverInfoData host:_host];
|
||||
_host.address = _host.externalAddress;
|
||||
receivedResponse = YES;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ static const float POLL_RATE = 2.0f; // Poll every 2 seconds
|
||||
HttpManager* hMan = [[HttpManager alloc] initWithHost:_host.address uniqueId:_uniqueId deviceName:deviceName cert:_cert];
|
||||
NSData* serverInfoData = [hMan executeRequestSynchronously:[hMan newServerInfoRequest]];
|
||||
if ([[HttpManager getStatusStringFromXML:serverInfoData] isEqualToString:@"OK"]) {
|
||||
[DiscoveryWorker updateHost:_host withServerInfo:serverInfoData];
|
||||
[HttpManager populateHostFromXML:serverInfoData host:_host];
|
||||
receivedResponse = YES;
|
||||
}
|
||||
}
|
||||
@@ -77,18 +77,4 @@ static const float POLL_RATE = 2.0f; // Poll every 2 seconds
|
||||
}
|
||||
}
|
||||
|
||||
+ (void) updateHost:(Host*)host withServerInfo:(NSData*)serverInfoData {
|
||||
host.name = [HttpManager getStringFromXML:serverInfoData tag:@"hostname"];
|
||||
host.externalAddress = [HttpManager getStringFromXML:serverInfoData tag:@"ExternalIP"];
|
||||
host.localAddress = [HttpManager getStringFromXML:serverInfoData tag:@"LocalIP"];
|
||||
host.uuid = [HttpManager getStringFromXML:serverInfoData tag:@"uniqueid"];
|
||||
host.mac = [HttpManager getStringFromXML:serverInfoData tag:@"mac"];
|
||||
NSString* pairState = [HttpManager getStringFromXML:serverInfoData tag:@"PairStatus"];
|
||||
if ([pairState isEqualToString:@"1"]) {
|
||||
host.pairState = PairStatePaired;
|
||||
} else {
|
||||
host.pairState = PairStateUnpaired;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user