5 // Created by Jens Alfke on 1/22/08.
6 // Copyright 2008 Jens Alfke. All rights reserved.
9 #import "MYDNSService.h"
10 @class MYBonjourBrowser, MYBonjourQuery, MYAddressLookup;
13 /** Represents a Bonjour service discovered by a MYBonjourBrowser. */
14 @interface MYBonjourService : MYDNSService
17 MYBonjourBrowser *_bonjourBrowser;
18 NSString *_name, *_fullName, *_type, *_domain, *_hostname;
19 uint32_t _interfaceIndex;
22 NSDictionary *_txtRecord;
23 MYBonjourQuery *_txtQuery;
24 MYAddressLookup *_addressLookup;
27 /** The browser I belong to. */
28 @property (readonly) MYBonjourBrowser *bonjourBrowser;
30 /** The service's name. */
31 @property (readonly) NSString *name;
33 /** The service's type. */
34 @property (readonly) NSString *type;
36 /** The service's domain. */
37 @property (readonly) NSString *domain;
39 /** The service's full name -- the name, type and domain concatenated together. */
40 @property (readonly,copy) NSString* fullName;
42 /** The index of the network interface on which this service was found. */
43 @property (readonly) uint32_t interfaceIndex;
47 * Getting the IP address of the service
51 /** The hostname of the machine providing this service. */
52 @property (readonly, copy) NSString *hostname;
54 /** The IP port number of this service on its host. */
55 @property (readonly) UInt16 port;
57 /** Returns a MYDNSLookup object that resolves the raw IP address(es) of this service.
58 Subsequent calls to this method will always return the same object. */
59 - (MYAddressLookup*) addressLookup;
64 /** @name TXT and other DNS records
68 /** The service's metadata dictionary, from its DNS TXT record */
69 @property (readonly,copy) NSDictionary *txtRecord;
71 /** A convenience to access a single property from the TXT record. */
72 - (NSString*) txtStringForKey: (NSString*)key;
74 /** Starts a new MYBonjourQuery for the specified DNS record type of this service.
75 @param recordType The DNS record type, e.g. kDNSServiceType_TXT; see the enum in <dns_sd.h>. */
76 - (MYBonjourQuery*) queryForRecord: (UInt16)recordType;
82 * Advanced methods that may be overridden by subclasses, but should not be called directly.
86 /** Designated initializer. You probably don't want to create MYBonjourService instances yourself,
87 but if you subclass you might need to override this initializer. */
88 - (id) initWithBrowser: (MYBonjourBrowser*)browser
89 name: (NSString*)serviceName
91 domain: (NSString*)domain
92 interface: (UInt32)interfaceIndex;
94 /** Called when this service is officially added to its browser's service set.
95 You can override this, but be sure to call the superclass method. */
98 /** Called when this service is officially removed to its browser's service set.
99 You can override this, but be sure to call the superclass method. */
102 /** Called when this service's TXT record changes.
103 You can override this, but be sure to call the superclass method. */
104 - (void) txtRecordChanged;
106 /** Called when a query started by this service updates.
107 You can override this, but be sure to call the superclass method. */
108 - (void) queryDidUpdate: (MYBonjourQuery*)query;