author | Jens Alfke <jens@mooseyard.com> |
Fri Jul 24 14:06:28 2009 -0700 (2009-07-24) | |
changeset 63 | 5e4855a592ee |
parent 50 | 63baa74c903f |
permissions | -rw-r--r-- |
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 //
9 #import "MYDNSService.h"
10 @class MYBonjourBrowser, MYBonjourQuery, MYAddressLookup;
13 /** Represents a Bonjour service discovered by a MYBonjourBrowser. */
14 @interface MYBonjourService : MYDNSService
15 {
16 @private
17 MYBonjourBrowser *_bonjourBrowser;
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 }
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;
46 /** @name Addressing
47 * Getting the IP address of the service
48 */
49 //@{
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;
61 //@}
64 /** @name TXT and other DNS records
65 */
66 //@{
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;
78 //@}
81 /** @name Protected
82 * Advanced methods that may be overridden by subclasses, but should not be called directly.
83 */
84 //@{
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
90 type: (NSString*)type
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. */
96 - (void) added;
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. */
100 - (void) removed;
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;
110 //@}
112 @end