Bonjour/MYBonjourService.h
author morrowa
Thu Jul 02 17:51:35 2009 -0700 (2009-07-02)
changeset 55 f240f9023393
parent 44 d8a559a39284
child 50 63baa74c903f
permissions -rw-r--r--
Made C99 project default.
     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 @class MYBonjourQuery, MYAddressLookup;
    11 
    12 
    13 /** Represents a Bonjour service discovered by a BonjourBrowser. */
    14 @interface MYBonjourService : MYDNSService 
    15 {
    16     @private
    17     NSString *_name, *_fullName, *_type, *_domain, *_hostname;
    18     uint32_t _interfaceIndex;
    19     BOOL _startedResolve;
    20     UInt16 _port;
    21     NSDictionary *_txtRecord;
    22     MYBonjourQuery *_txtQuery;
    23     MYAddressLookup *_addressLookup;
    24 }
    25 
    26 /** The service's name. */
    27 @property (readonly) NSString *name;
    28 
    29 /** The service's type. */
    30 @property (readonly) NSString *type;
    31 
    32 /** The service's domain. */
    33 @property (readonly) NSString *domain;
    34 
    35 /** The service's full name -- the name, type and domain concatenated together. */
    36 @property (readonly,copy) NSString* fullName;
    37 
    38 /** The index of the network interface on which this service was found. */
    39 @property (readonly) uint32_t interfaceIndex;
    40 
    41 
    42 /** @name Addressing
    43  *  Getting the IP address of the service
    44  */
    45 //@{
    46 
    47 /** The hostname of the machine providing this service. */
    48 @property (readonly, copy) NSString *hostname;
    49 
    50 /** The IP port number of this service on its host. */
    51 @property (readonly) UInt16 port;
    52 
    53 /** Returns a MYDNSLookup object that resolves the raw IP address(es) of this service.
    54     Subsequent calls to this method will always return the same object. */
    55 - (MYAddressLookup*) addressLookup;
    56 
    57 //@}
    58 
    59 
    60 /** @name TXT and other DNS records
    61  */
    62 //@{
    63 
    64 /** The service's metadata dictionary, from its DNS TXT record */
    65 @property (readonly,copy) NSDictionary *txtRecord;
    66 
    67 /** A convenience to access a single property from the TXT record. */
    68 - (NSString*) txtStringForKey: (NSString*)key;
    69 
    70 /** Starts a new MYBonjourQuery for the specified DNS record type of this service.
    71     @param recordType  The DNS record type, e.g. kDNSServiceType_TXT; see the enum in <dns_sd.h>. */
    72 - (MYBonjourQuery*) queryForRecord: (UInt16)recordType;
    73 
    74 //@}
    75 
    76 
    77 /** @name Protected
    78  *  Advanced methods that may be overridden by subclasses, but should not be called directly.
    79  */
    80 //@{
    81 
    82 /** Designated initializer. You probably don't want to create MYBonjourService instances yourself,
    83     but if you subclass you might need to override this initializer. */
    84 - (id) initWithName: (NSString*)serviceName
    85                type: (NSString*)type
    86              domain: (NSString*)domain
    87           interface: (UInt32)interfaceIndex;
    88 
    89 /** Called when this service is officially added to its browser's service set.
    90     You can override this, but be sure to call the superclass method. */
    91 - (void) added;
    92 
    93 /** Called when this service is officially removed to its browser's service set.
    94     You can override this, but be sure to call the superclass method. */
    95 - (void) removed;
    96 
    97 /** Called when this service's TXT record changes.
    98     You can override this, but be sure to call the superclass method. */
    99 - (void) txtRecordChanged;
   100 
   101 /** Called when a query started by this service updates.
   102     You can override this, but be sure to call the superclass method. */
   103 - (void) queryDidUpdate: (MYBonjourQuery*)query;
   104 
   105 //@}
   106 
   107 @end