mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2025-07-27 06:32:59 +00:00
No longer duplicate hosts when the same host is discovered by MDNS
This commit is contained in:
parent
57bf748877
commit
d4cd8d3bba
@ -99,18 +99,28 @@
|
||||
[_hostQueue removeObject:host];
|
||||
}
|
||||
|
||||
// Override from MDNSCallback
|
||||
- (void)updateHosts:(NSArray *)hosts {
|
||||
for (Host* host in hosts) {
|
||||
if ([self addHostToDiscovery:host]) {
|
||||
[_callback updateAllHosts:_hostQueue];
|
||||
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) {
|
||||
// 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]) {
|
||||
[_callback updateAllHosts:_hostQueue];
|
||||
} else {
|
||||
[dataMan removeHost:host];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (BOOL) isHostInDiscovery:(Host*)host {
|
||||
for (int i = 0; i < _hostQueue.count; i++) {
|
||||
Host* discoveredHost = [_hostQueue objectAtIndex:i];
|
||||
if ([discoveredHost.uuid isEqualToString:host.uuid]) {
|
||||
if (discoveredHost.uuid.length > 0 && [discoveredHost.uuid isEqualToString:host.uuid]) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user