Bonjour/MYBonjourService.h
author Jens Alfke <jens@mooseyard.com>
Mon Apr 27 09:03:56 2009 -0700 (2009-04-27)
changeset 28 732576fa8a0d
parent 26 cb9cdf247239
child 31 1d6924779df7
permissions -rw-r--r--
Rewrote the Bonjour classes, using the low-level <dns_sd.h> API. They're now subclasses of MYDNSService.
     1 //
     2 //  MYBonjourService.h
     3 //  MYNetwork
     4 //
     5 //  Created by Jens Alfke on 1/22/08.
     6 //  Copyright 2008 Jens Alfke. All rights reserved.
     7 //
     8 
     9 #import "MYDNSService.h"
    10 #import "ConcurrentOperation.h"
    11 @class MYBonjourQuery, MYAddressLookup;
    12 
    13 
    14 /** Represents a Bonjour service discovered by a BonjourBrowser. */
    15 @interface MYBonjourService : MYDNSService 
    16 {
    17     @private
    18     NSString *_name, *_fullName, *_type, *_domain, *_hostname;
    19     uint32_t _interfaceIndex;
    20     BOOL _startedResolve;
    21     UInt16 _port;
    22     NSDictionary *_txtRecord;
    23     MYBonjourQuery *_txtQuery;
    24     MYAddressLookup *_addressLookup;
    25 }
    26 
    27 /** The service's name. */
    28 @property (readonly) NSString *name;
    29 
    30 /** The service's type. */
    31 @property (readonly) NSString *type;
    32 
    33 /** The service's domain. */
    34 @property (readonly) NSString *domain;
    35 
    36 @property (readonly, copy) NSString *hostname;
    37 
    38 @property (readonly) UInt16 port;
    39 
    40 @property (readonly) uint32_t interfaceIndex;
    41 
    42 @property (readonly,copy) NSString* fullName;
    43 
    44 /** The service's metadata dictionary, from its DNS TXT record */
    45 @property (readonly,copy) NSDictionary *txtRecord;
    46 
    47 /** A convenience to access a single property from the TXT record. */
    48 - (NSString*) txtStringForKey: (NSString*)key;
    49 
    50 /** Returns a MYDNSLookup object that resolves the IP address(es) of this service.
    51     Subsequent calls to this method will always return the same object. */
    52 - (MYAddressLookup*) addressLookup;
    53 
    54 /** Starts a new MYBonjourQuery for the specified DNS record type of this service.
    55     @param recordType  The DNS record type, e.g. kDNSServiceType_TXT; see the enum in <dns_sd.h>. */
    56 - (MYBonjourQuery*) queryForRecord: (UInt16)recordType;
    57 
    58 
    59 // Protected methods, for subclass use only:
    60 
    61 // (for subclasses to override, but not call):
    62 - (id) initWithName: (NSString*)serviceName
    63                type: (NSString*)type
    64              domain: (NSString*)domain
    65           interface: (uint32_t)interfaceIndex;
    66 
    67 - (void) added;
    68 - (void) removed;
    69 - (void) txtRecordChanged;
    70 
    71 // Internal:
    72 
    73 - (void) queryDidUpdate: (MYBonjourQuery*)query;
    74 
    75 @end
    76 
    77 
    78 
    79 @interface MYBonjourResolveOperation : ConcurrentOperation
    80 {
    81     MYBonjourService *_service;
    82     NSSet *_addresses;
    83 }
    84 
    85 @property (readonly) MYBonjourService *service;
    86 @property (readonly,retain) NSSet *addresses;
    87 
    88 @end