X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/89e6aacd25d9f355b9dac9c22973e6a5161b3f88..92cf4bdca5f1a76e6feec10a0d9ea32b51f286e8:/NetworkController.m?ds=inline diff --git a/NetworkController.m b/NetworkController.m index 3ac6250..d6bfca0 100755 --- a/NetworkController.m +++ b/NetworkController.m @@ -13,8 +13,6 @@ #import "NetworkController.h" #import "MainController.h" -#import "netinet/in.h" -#import "arpa/inet.h" #import #import #import @@ -159,9 +157,19 @@ static NetworkController *sharedController; - (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didFindService:(NSNetService *)aNetService moreComing:(BOOL)moreComing { + ITDebugLog(@"Found service named %@.", [aNetService name]); + [remoteServices addObject:aNetService]; [aNetService setDelegate:self]; [aNetService resolve]; - ITDebugLog(@"Found service named %@.", [aNetService name]); + if (!moreComing) { + [[NSNotificationCenter defaultCenter] postNotificationName:@"ITMTFoundNetService" object:nil]; + } +} + +- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didRemoveService:(NSNetService*)aNetService moreComing:(BOOL)moreComing +{ + ITDebugLog(@"Removed service named %@.", [aNetService name]); + [remoteServices removeObject:aNetService]; if (!moreComing) { [[NSNotificationCenter defaultCenter] postNotificationName:@"ITMTFoundNetService" object:nil]; } @@ -169,11 +177,8 @@ static NetworkController *sharedController; - (void)netServiceDidResolveAddress:(NSNetService *)sender { - [remoteServices addObject:[NSDictionary dictionaryWithObjectsAndKeys:[sender name], @"name", - [NSString stringWithCString:inet_ntoa((*(struct sockaddr_in*)[[[sender addresses] objectAtIndex:0] bytes]).sin_addr)], @"ip", - nil, nil]]; ITDebugLog(@"Resolved service named %@.", [sender name]); - NSLog(@"found!"); + NSLog(@"Resolved service named %@.", [sender name]); [[NSNotificationCenter defaultCenter] postNotificationName:@"ITMTFoundNetService" object:nil]; }