Allow rediscovery of hosts after deletion without having to force quit the app

This commit is contained in:
Cameron Gutman 2020-04-18 15:03:52 -07:00
parent bd5e0ecc40
commit b8631db5df
5 changed files with 13 additions and 0 deletions

View File

@ -21,6 +21,7 @@
- (void) startDiscovery;
- (void) stopDiscovery;
- (void) stopDiscoveryBlocking;
- (void) resetDiscoveryState;
- (BOOL) addHostToDiscovery:(TemporaryHost*)host;
- (void) removeHostFromDiscovery:(TemporaryHost*)host;
- (void) discoverHost:(NSString*)hostAddress withCallback:(void (^)(TemporaryHost*, NSString*))callback;

View File

@ -69,6 +69,11 @@
}
- (void) resetDiscoveryState {
// Allow us to rediscover hosts that were already found before
[_mdnsMan forgetHosts];
}
- (void) startDiscovery {
if (shouldDiscover) {
return;

View File

@ -21,6 +21,7 @@
- (id) initWithCallback:(id<MDNSCallback>) callback;
- (void) searchForHosts;
- (void) stopSearching;
- (void) forgetHosts;
@end

View File

@ -63,6 +63,10 @@ static NSString* NV_SERVICE_TYPE = @"_nvstream._tcp";
[mDNSBrowser stop];
}
- (void) forgetHosts {
[services removeAllObjects];
}
+ (NSString*)sockAddrToString:(NSData*)addrData {
char addrStr[INET6_ADDRSTRLEN];
struct sockaddr* addr = (struct sockaddr*)[addrData bytes];

View File

@ -829,6 +829,8 @@ static NSMutableSet* hostList;
// This will kick off box art caching
[self updateHosts];
// Reset state first so we can rediscover hosts that were deleted before
[_discMan resetDiscoveryState];
[_discMan startDiscovery];
// This will refresh the applist when a paired host is selected