Fix streaming over the external IP address when discovered via mDNS

This commit is contained in:
Cameron Gutman
2015-07-10 00:28:51 -07:00
parent 48d1c1a080
commit 935fb6ffe3
7 changed files with 27 additions and 10 deletions

View File

@@ -31,7 +31,7 @@ static const int MAX_ATTEMPTS = 5;
}
}
if (appImage == nil) {
HttpManager* hMan = [[HttpManager alloc] initWithHost:_host.address uniqueId:[CryptoManager getUniqueID] deviceName:deviceName cert:[CryptoManager readCertFromFile]];
HttpManager* hMan = [[HttpManager alloc] initWithHost:_host.activeAddress uniqueId:[CryptoManager getUniqueID] deviceName:deviceName cert:[CryptoManager readCertFromFile]];
AppAssetResponse* appAssetResp = [[AppAssetResponse alloc] init];
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:appAssetResp withUrlRequest:[hMan newAppAssetRequestWithAppId:self.app.appId]]];

View File

@@ -47,7 +47,7 @@
if ([serverInfoResponse isStatusOk]) {
DataManager* dataMan = [[DataManager alloc] init];
host = [dataMan createHost];
host.address = hostAddress;
host.activeAddress = host.address = hostAddress;
host.online = YES;
[serverInfoResponse populateHost:host];
if (![self addHostToDiscovery:host]) {

View File

@@ -46,18 +46,27 @@ static const float POLL_RATE = 2.0f; // Poll every 2 seconds
if (!self.cancelled && _host.localAddress != nil) {
ServerInfoResponse* serverInfoResp = [self requestInfoAtAddress:_host.localAddress];
receivedResponse = [self checkResponse:serverInfoResp];
if (receivedResponse) {
_host.activeAddress = _host.localAddress;
}
}
if (!self.cancelled && !receivedResponse && _host.externalAddress != nil) {
ServerInfoResponse* serverInfoResp = [self requestInfoAtAddress:_host.externalAddress];
receivedResponse = [self checkResponse:serverInfoResp];
if (receivedResponse) {
_host.activeAddress = _host.externalAddress;
}
}
if (!self.cancelled && !receivedResponse && _host.address != nil) {
ServerInfoResponse* serverInfoResp = [self requestInfoAtAddress:_host.address];
receivedResponse = [self checkResponse:serverInfoResp];
if (receivedResponse) {
_host.activeAddress = _host.address;
}
}
_host.online = 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}", _host.name, _host.address, _host.localAddress, _host.externalAddress, _host.uuid, _host.mac, _host.pairState, _host.online);
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);
}
}

View File

@@ -51,7 +51,7 @@ static NSString* NV_SERVICE_TYPE = @"_nvstream._tcp";
for (NSNetService* service in services) {
if (service.hostName != nil) {
Host* host = [dataMan createHost];
host.address = service.hostName;
host.activeAddress = host.address = service.hostName;
host.name = host.address;
[hosts addObject:host];
}