Bonjour/MYBonjourService.h
author Jens Alfke <jens@mooseyard.com>
Sat May 16 14:24:06 2009 -0700 (2009-05-16)
changeset 48 2b4ad2067074
parent 43 aab592ac36fc
child 49 20cccc7c26ee
permissions -rw-r--r--
Yuck -- [TCPConnection initToBonjourService:] was releasing the wrong object, the BonjourService, causing it to dealloc and eventually crash. Fixes #10.
     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 /** The service's full name -- the name, type and domain concatenated together. */
    37 @property (readonly,copy) NSString* fullName;
    38 
    39 /** The index of the network interface on which this service was found. */
    40 @property (readonly) uint32_t interfaceIndex;
    41 
    42 
    43 /** @name Addressing
    44  *  Getting the IP address of the service
    45  */
    46 //@{
    47 
    48 /** The hostname of the machine providing this service. */
    49 @property (readonly, copy) NSString *hostname;
    50 
    51 /** The IP port number of this service on its host. */
    52 @property (readonly) UInt16 port;
    53 
    54 /** Returns a MYDNSLookup object that resolves the raw IP address(es) of this service.
    55     Subsequent calls to this method will always return the same object. */
    56 - (MYAddressLookup*) addressLookup;
    57 
    58 //@}
    59 
    60 
    61 /** @name TXT and other DNS records
    62  */
    63 //@{
    64 
    65 /** The service's metadata dictionary, from its DNS TXT record */
    66 @property (readonly,copy) NSDictionary *txtRecord;
    67 
    68 /** A convenience to access a single property from the TXT record. */
    69 - (NSString*) txtStringForKey: (NSString*)key;
    70 
    71 /** Starts a new MYBonjourQuery for the specified DNS record type of this service.
    72     @param recordType  The DNS record type, e.g. kDNSServiceType_TXT; see the enum in <dns_sd.h>. */
    73 - (MYBonjourQuery*) queryForRecord: (UInt16)recordType;
    74 
    75 //@}
    76 
    77 
    78 /** @name Protected
    79  *  Advanced methods that may be overridden by subclasses, but should not be called directly.
    80  */
    81 //@{
    82 
    83 /** Designated initializer. You probably don't want to create MYBonjourService instances yourself,
    84     but if you subclass you might need to override this initializer. */
    85 - (id) initWithName: (NSString*)serviceName
    86                type: (NSString*)type
    87              domain: (NSString*)domain
    88           interface: (UInt32)interfaceIndex;
    89 
    90 /** Called when this service is officially added to its browser's service set.
    91     You can override this, but be sure to call the superclass method. */
    92 - (void) added;
    93 
    94 /** Called when this service is officially removed to its browser's service set.
    95     You can override this, but be sure to call the superclass method. */
    96 - (void) removed;
    97 
    98 /** Called when this service's TXT record changes.
    99     You can override this, but be sure to call the superclass method. */
   100 - (void) txtRecordChanged;
   101 
   102 /** Called when a query started by this service updates.
   103     You can override this, but be sure to call the superclass method. */
   104 - (void) queryDidUpdate: (MYBonjourQuery*)query;
   105 
   106 //@}
   107 
   108 @end