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 @@ ...@@ -23,6 +23,8 @@
@property (nonatomic, readonly) NSString *serviceType; @property (nonatomic, readonly) NSString *serviceType;
@property (nonatomic, readonly) NSString *domain; @property (nonatomic, readonly) NSString *domain;
@property (nonatomic, readonly, getter=isDiscovering) BOOL discovering;
@property (nonatomic, readonly) NSMutableArray<NSNetService*> *rawNetServices; @property (nonatomic, readonly) NSMutableArray<NSNetService*> *rawNetServices;
@property (nonatomic, readonly) NSMutableArray<VLCLocalNetworkServiceNetService*> *resolvedLocalNetworkServices; @property (nonatomic, readonly) NSMutableArray<VLCLocalNetworkServiceNetService*> *resolvedLocalNetworkServices;
......
...@@ -65,10 +65,15 @@ ...@@ -65,10 +65,15 @@
return self.resolvedLocalNetworkServices.count; return self.resolvedLocalNetworkServices.count;
} }
- (void)startDiscovery { - (void)startDiscovery {
if (self.isDiscovering) {
return;
}
_discovering = YES;
[self.netServiceBrowser searchForServicesOfType:self.serviceType inDomain:self.domain]; [self.netServiceBrowser searchForServicesOfType:self.serviceType inDomain:self.domain];
} }
- (void)stopDiscovery { - (void)stopDiscovery {
[self.netServiceBrowser stop]; [self.netServiceBrowser stop];
_discovering = NO;
} }
- (id<VLCLocalNetworkService>)networkServiceForIndex:(NSUInteger)index { - (id<VLCLocalNetworkService>)networkServiceForIndex:(NSUInteger)index {
return self.resolvedLocalNetworkServices[index]; return self.resolvedLocalNetworkServices[index];
...@@ -90,6 +95,10 @@ ...@@ -90,6 +95,10 @@
[self.delegate localNetworkServiceBrowserDidUpdateServices:self]; [self.delegate localNetworkServiceBrowserDidUpdateServices:self];
} }
} }
- (void)netServiceBrowser:(NSNetServiceBrowser *)browser didNotSearch:(NSDictionary<NSString *,NSNumber *> *)errorDict {
APLog(@"bonjour service did not search: %@ %@", browser, errorDict);
}
#pragma mark - NSNetServiceDelegate #pragma mark - NSNetServiceDelegate
- (void)netServiceDidResolveAddress:(NSNetService *)sender { - (void)netServiceDidResolveAddress:(NSNetService *)sender {
......
...@@ -66,13 +66,11 @@ ...@@ -66,13 +66,11 @@
}]; }];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netReachabilityChanged) name:kReachabilityChangedNotification object:nil];
_reachability = [Reachability reachabilityForLocalWiFi]; _reachability = [Reachability reachabilityForLocalWiFi];
[_reachability startNotifier]; [_reachability startNotifier];
[self netReachabilityChanged];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netReachabilityChanged) name:kReachabilityChangedNotification object:nil];
return self; 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