1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/Bonjour/MYBonjourService.h Sun Apr 26 18:12:44 2009 -0700
1.3 @@ -0,0 +1,70 @@
1.4 +//
1.5 +// MYBonjourService.h
1.6 +// MYNetwork
1.7 +//
1.8 +// Created by Jens Alfke on 1/22/08.
1.9 +// Copyright 2008 Jens Alfke. All rights reserved.
1.10 +//
1.11 +
1.12 +#import <Foundation/Foundation.h>
1.13 +#import "ConcurrentOperation.h"
1.14 +@class MYBonjourResolveOperation;
1.15 +
1.16 +
1.17 +/** Represents a Bonjour service discovered by a BonjourBrowser. */
1.18 +@interface MYBonjourService : NSObject
1.19 +{
1.20 + @private
1.21 + NSNetService *_netService;
1.22 + NSDictionary *_txtRecord;
1.23 + NSSet *_addresses;
1.24 + CFAbsoluteTime _addressesExpireAt;
1.25 + MYBonjourResolveOperation *_resolveOp;
1.26 +}
1.27 +
1.28 +/** The service's name. */
1.29 +@property (readonly) NSString *name;
1.30 +
1.31 +/** The service's metadata dictionary, from its DNS TXT record */
1.32 +@property (readonly,copy) NSDictionary *txtRecord;
1.33 +
1.34 +/** A convenience to access a single property from the TXT record. */
1.35 +- (NSString*) txtStringForKey: (NSString*)key;
1.36 +
1.37 +/** Returns a set of IPAddress objects; may be the empty set if address resolution failed,
1.38 + or nil if addresses have not been resolved yet (or expired).
1.39 + In the latter case, call -resolve and wait for the returned Operation to finish. */
1.40 +@property (readonly,copy) NSSet* addresses;
1.41 +
1.42 +/** Starts looking up the IP address(es) of this service.
1.43 + @return The NSOperation representing the lookup; you can observe this to see when it
1.44 + completes, or you can observe the service's 'addresses' property. */
1.45 +- (MYBonjourResolveOperation*) resolve;
1.46 +
1.47 +/** The underlying NSNetSerice object. */
1.48 +@property (readonly) NSNetService *netService;
1.49 +
1.50 +
1.51 +// Protected methods, for subclass use only:
1.52 +
1.53 +- (id) initWithNetService: (NSNetService*)netService;
1.54 +
1.55 +// (for subclasses to override, but not call):
1.56 +- (void) added;
1.57 +- (void) removed;
1.58 +- (void) txtRecordChanged;
1.59 +
1.60 +@end
1.61 +
1.62 +
1.63 +
1.64 +@interface MYBonjourResolveOperation : ConcurrentOperation
1.65 +{
1.66 + MYBonjourService *_service;
1.67 + NSSet *_addresses;
1.68 +}
1.69 +
1.70 +@property (readonly) MYBonjourService *service;
1.71 +@property (readonly,retain) NSSet *addresses;
1.72 +
1.73 +@end