Commit 85f48bed authored by Tobias's avatar Tobias
Browse files

fix net service based discovery (FTP/Plex/HTTP) by guarding against starting discovery twice

parent 26bdb0ca
......@@ -23,6 +23,8 @@
@property (nonatomic, readonly) NSString *serviceType;
@property (nonatomic, readonly) NSString *domain;
@property (nonatomic, readonly, getter=isDiscovering) BOOL discovering;
@property (nonatomic, readonly) NSMutableArray<NSNetService*> *rawNetServices;
@property (nonatomic, readonly) NSMutableArray<VLCLocalNetworkServiceNetService*> *resolvedLocalNetworkServices;
......
......@@ -65,10 +65,15 @@
return self.resolvedLocalNetworkServices.count;
}
- (void)startDiscovery {
if (self.isDiscovering) {
return;
}
_discovering = YES;
[self.netServiceBrowser searchForServicesOfType:self.serviceType inDomain:self.domain];
}
- (void)stopDiscovery {
[self.netServiceBrowser stop];
_discovering = NO;
}
- (id<VLCLocalNetworkService>)networkServiceForIndex:(NSUInteger)index {
return self.resolvedLocalNetworkServices[index];
......@@ -90,6 +95,10 @@
[self.delegate localNetworkServiceBrowserDidUpdateServices:self];
}
}
- (void)netServiceBrowser:(NSNetServiceBrowser *)browser didNotSearch:(NSDictionary<NSString *,NSNumber *> *)errorDict {
APLog(@"bonjour service did not search: %@ %@", browser, errorDict);
}
#pragma mark - NSNetServiceDelegate
- (void)netServiceDidResolveAddress:(NSNetService *)sender {
......
......@@ -66,13 +66,11 @@
}];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netReachabilityChanged) name:kReachabilityChangedNotification object:nil];
_reachability = [Reachability reachabilityForLocalWiFi];
[_reachability startNotifier];
[self netReachabilityChanged];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netReachabilityChanged) name:kReachabilityChangedNotification object:nil];
return self;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment