Give me a B! Give me a U! Give me a G!
[ITFoundation.git] / ITServiceBrowserDelegate.m
index 0dfcce8..6d368c6 100755 (executable)
 {
     if (self = [super init])
           {
 {
     if (self = [super init])
           {
-          delegate = _delegate;
+          delegate = [_delegate retain];
           }
     return self;
 }
 
           }
     return self;
 }
 
+- (void) dealloc
+{
+    [delegate release];
+}
+
 - (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didFindService:(NSNetService *)aNetService moreComing:(BOOL)moreComing
 {
     ITInetSocket *sock;
 - (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didFindService:(NSNetService *)aNetService moreComing:(BOOL)moreComing
 {
     ITInetSocket *sock;
+    NSArray *arr;
+    id d = delegate;
     if (!moreComing)
           {
     if (!moreComing)
           {
+          NSLog(@"Nothing more coming");
+          [[aNetService retain] autorelease];
           [aNetServiceBrowser stop];
           [aNetServiceBrowser release];
           [aNetServiceBrowser stop];
           [aNetServiceBrowser release];
+          [self release];
           }
           }
-    sock = [[ITInetSocket alloc] initWithDelegate:delegate];
-    [sock connectWithSockaddrArray:[aNetService addresses]];
+    sock = [[ITInetSocket alloc] initWithDelegate:d];
+    NSLog(@"Detected a service! name %@ type %@",[aNetService name],[aNetService type]);
+    arr = [aNetService addresses];
+    if ([arr count])
+          [sock connectWithSockaddrArray:arr];
+    else
+          NSLog(@"There are no sockaddrs for this service!");
 }
 
 @end
 }
 
 @end