mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-15 21:21:45 +00:00
No longer duplicate hosts when the same host is discovered by MDNS
This commit is contained in:
@@ -99,18 +99,28 @@
|
|||||||
[_hostQueue removeObject:host];
|
[_hostQueue removeObject:host];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Override from MDNSCallback
|
||||||
- (void)updateHosts:(NSArray *)hosts {
|
- (void)updateHosts:(NSArray *)hosts {
|
||||||
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
|
DataManager* dataMan = [[DataManager alloc] init];
|
||||||
|
// Discover the hosts before adding to eliminate duplicates
|
||||||
for (Host* host in hosts) {
|
for (Host* host in hosts) {
|
||||||
|
// Since this is on a background thread, we do not need to use the opQueue
|
||||||
|
NSOperation* worker = [self createWorkerForHost:host];
|
||||||
|
[worker main];
|
||||||
if ([self addHostToDiscovery:host]) {
|
if ([self addHostToDiscovery:host]) {
|
||||||
[_callback updateAllHosts:_hostQueue];
|
[_callback updateAllHosts:_hostQueue];
|
||||||
|
} else {
|
||||||
|
[dataMan removeHost:host];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) isHostInDiscovery:(Host*)host {
|
- (BOOL) isHostInDiscovery:(Host*)host {
|
||||||
for (int i = 0; i < _hostQueue.count; i++) {
|
for (int i = 0; i < _hostQueue.count; i++) {
|
||||||
Host* discoveredHost = [_hostQueue objectAtIndex:i];
|
Host* discoveredHost = [_hostQueue objectAtIndex:i];
|
||||||
if ([discoveredHost.uuid isEqualToString:host.uuid]) {
|
if (discoveredHost.uuid.length > 0 && [discoveredHost.uuid isEqualToString:host.uuid]) {
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user