From 920cbadc911c048653b17c8c960fb09153004f86 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 29 Sep 2015 00:04:40 -0700 Subject: [PATCH] Add a workaround/hack to fix duplicating machines --- Limelight/Network/DiscoveryManager.m | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Limelight/Network/DiscoveryManager.m b/Limelight/Network/DiscoveryManager.m index 0757e20..f2c4dea 100644 --- a/Limelight/Network/DiscoveryManager.m +++ b/Limelight/Network/DiscoveryManager.m @@ -27,14 +27,29 @@ - (id)initWithHosts:(NSArray *)hosts andCallback:(id)callback { self = [super init]; - _hostQueue = [NSMutableArray arrayWithArray:hosts]; + + // Using addHostToDiscovery ensures no duplicates + // will make it into the list from the database _callback = callback; + shouldDiscover = NO; + _hostQueue = [NSMutableArray array]; + DataManager* dataMan = [[DataManager alloc] init]; + for (Host* host in hosts) + { + if (![self addHostToDiscovery:host]) + { + // Remove the duplicate host from the database + [dataMan removeHost:host]; + } + } + [dataMan saveData]; + [_callback updateAllHosts:_hostQueue]; + _opQueue = [[NSOperationQueue alloc] init]; _mdnsMan = [[MDNSManager alloc] initWithCallback:self]; [CryptoManager generateKeyPairUsingSSl]; _uniqueId = [CryptoManager getUniqueID]; _cert = [CryptoManager readCertFromFile]; - shouldDiscover = NO; return self; }