Bonjour/MYBonjourService.h
changeset 29 59689fbdcf77
parent 26 cb9cdf247239
child 31 1d6924779df7
     1.1 --- a/Bonjour/MYBonjourService.h	Wed Apr 22 16:45:39 2009 -0700
     1.2 +++ b/Bonjour/MYBonjourService.h	Tue Apr 28 10:36:28 2009 -0700
     1.3 @@ -6,54 +6,72 @@
     1.4  //  Copyright 2008 Jens Alfke. All rights reserved.
     1.5  //
     1.6  
     1.7 -#import <Foundation/Foundation.h>
     1.8 +#import "MYDNSService.h"
     1.9  #import "ConcurrentOperation.h"
    1.10 -@class MYBonjourResolveOperation;
    1.11 +@class MYBonjourQuery, MYAddressLookup;
    1.12  
    1.13  
    1.14  /** Represents a Bonjour service discovered by a BonjourBrowser. */
    1.15 -@interface MYBonjourService : NSObject 
    1.16 +@interface MYBonjourService : MYDNSService 
    1.17  {
    1.18      @private
    1.19 -    NSNetService *_netService;
    1.20 +    NSString *_name, *_fullName, *_type, *_domain, *_hostname;
    1.21 +    uint32_t _interfaceIndex;
    1.22 +    BOOL _startedResolve;
    1.23 +    UInt16 _port;
    1.24      NSDictionary *_txtRecord;
    1.25 -    NSSet *_addresses;
    1.26 -    CFAbsoluteTime _addressesExpireAt;
    1.27 -    MYBonjourResolveOperation *_resolveOp;
    1.28 +    MYBonjourQuery *_txtQuery;
    1.29 +    MYAddressLookup *_addressLookup;
    1.30  }
    1.31  
    1.32  /** The service's name. */
    1.33  @property (readonly) NSString *name;
    1.34  
    1.35 +/** The service's type. */
    1.36 +@property (readonly) NSString *type;
    1.37 +
    1.38 +/** The service's domain. */
    1.39 +@property (readonly) NSString *domain;
    1.40 +
    1.41 +@property (readonly, copy) NSString *hostname;
    1.42 +
    1.43 +@property (readonly) UInt16 port;
    1.44 +
    1.45 +@property (readonly) uint32_t interfaceIndex;
    1.46 +
    1.47 +@property (readonly,copy) NSString* fullName;
    1.48 +
    1.49  /** The service's metadata dictionary, from its DNS TXT record */
    1.50  @property (readonly,copy) NSDictionary *txtRecord;
    1.51  
    1.52  /** A convenience to access a single property from the TXT record. */
    1.53  - (NSString*) txtStringForKey: (NSString*)key;
    1.54  
    1.55 -/** Returns a set of IPAddress objects; may be the empty set if address resolution failed,
    1.56 -    or nil if addresses have not been resolved yet (or expired).
    1.57 -    In the latter case, call -resolve and wait for the returned Operation to finish. */
    1.58 -@property (readonly,copy) NSSet* addresses;
    1.59 +/** Returns a MYDNSLookup object that resolves the IP address(es) of this service.
    1.60 +    Subsequent calls to this method will always return the same object. */
    1.61 +- (MYAddressLookup*) addressLookup;
    1.62  
    1.63 -/** Starts looking up the IP address(es) of this service.
    1.64 -    @return  The NSOperation representing the lookup; you can observe this to see when it
    1.65 -        completes, or you can observe the service's 'addresses' property. */
    1.66 -- (MYBonjourResolveOperation*) resolve;
    1.67 -
    1.68 -/** The underlying NSNetSerice object. */
    1.69 -@property (readonly) NSNetService *netService;
    1.70 +/** Starts a new MYBonjourQuery for the specified DNS record type of this service.
    1.71 +    @param recordType  The DNS record type, e.g. kDNSServiceType_TXT; see the enum in <dns_sd.h>. */
    1.72 +- (MYBonjourQuery*) queryForRecord: (UInt16)recordType;
    1.73  
    1.74  
    1.75  // Protected methods, for subclass use only:
    1.76  
    1.77 -- (id) initWithNetService: (NSNetService*)netService;
    1.78 +// (for subclasses to override, but not call):
    1.79 +- (id) initWithName: (NSString*)serviceName
    1.80 +               type: (NSString*)type
    1.81 +             domain: (NSString*)domain
    1.82 +          interface: (uint32_t)interfaceIndex;
    1.83  
    1.84 -// (for subclasses to override, but not call):
    1.85  - (void) added;
    1.86  - (void) removed;
    1.87  - (void) txtRecordChanged;
    1.88  
    1.89 +// Internal:
    1.90 +
    1.91 +- (void) queryDidUpdate: (MYBonjourQuery*)query;
    1.92 +
    1.93  @end
    1.94  
    1.95