jens@26: // jens@26: // MYBonjourService.h jens@26: // MYNetwork jens@26: // jens@26: // Created by Jens Alfke on 1/22/08. jens@26: // Copyright 2008 Jens Alfke. All rights reserved. jens@26: // jens@26: jens@26: #import jens@26: #import "ConcurrentOperation.h" jens@26: @class MYBonjourResolveOperation; jens@26: jens@26: jens@26: /** Represents a Bonjour service discovered by a BonjourBrowser. */ jens@26: @interface MYBonjourService : NSObject jens@26: { jens@26: @private jens@26: NSNetService *_netService; jens@26: NSDictionary *_txtRecord; jens@26: NSSet *_addresses; jens@26: CFAbsoluteTime _addressesExpireAt; jens@26: MYBonjourResolveOperation *_resolveOp; jens@26: } jens@26: jens@26: /** The service's name. */ jens@26: @property (readonly) NSString *name; jens@26: jens@26: /** The service's metadata dictionary, from its DNS TXT record */ jens@26: @property (readonly,copy) NSDictionary *txtRecord; jens@26: jens@26: /** A convenience to access a single property from the TXT record. */ jens@26: - (NSString*) txtStringForKey: (NSString*)key; jens@26: jens@26: /** Returns a set of IPAddress objects; may be the empty set if address resolution failed, jens@26: or nil if addresses have not been resolved yet (or expired). jens@26: In the latter case, call -resolve and wait for the returned Operation to finish. */ jens@26: @property (readonly,copy) NSSet* addresses; jens@26: jens@26: /** Starts looking up the IP address(es) of this service. jens@26: @return The NSOperation representing the lookup; you can observe this to see when it jens@26: completes, or you can observe the service's 'addresses' property. */ jens@26: - (MYBonjourResolveOperation*) resolve; jens@26: jens@26: /** The underlying NSNetSerice object. */ jens@26: @property (readonly) NSNetService *netService; jens@26: jens@26: jens@26: // Protected methods, for subclass use only: jens@26: jens@26: - (id) initWithNetService: (NSNetService*)netService; jens@26: jens@26: // (for subclasses to override, but not call): jens@26: - (void) added; jens@26: - (void) removed; jens@26: - (void) txtRecordChanged; jens@26: jens@26: @end jens@26: jens@26: jens@26: jens@26: @interface MYBonjourResolveOperation : ConcurrentOperation jens@26: { jens@26: MYBonjourService *_service; jens@26: NSSet *_addresses; jens@26: } jens@26: jens@26: @property (readonly) MYBonjourService *service; jens@26: @property (readonly,retain) NSSet *addresses; jens@26: jens@26: @end