jens@26: // jens@26: // MYBonjourService.h jens@26: // MYNetwork jens@26: // jens@26: // Created by Jens Alfke on 1/22/08. jens@26: // Copyright 2008 Jens Alfke. All rights reserved. jens@26: // jens@26: jens@28: #import "MYDNSService.h" jens@59: @class MYBonjourBrowser, MYBonjourQuery, MYAddressLookup; jens@26: jens@26: jens@50: /** Represents a Bonjour service discovered by a MYBonjourBrowser. */ jens@28: @interface MYBonjourService : MYDNSService jens@26: { jens@26: @private jens@59: MYBonjourBrowser *_bonjourBrowser; jens@28: NSString *_name, *_fullName, *_type, *_domain, *_hostname; jens@28: uint32_t _interfaceIndex; jens@28: BOOL _startedResolve; jens@28: UInt16 _port; jens@26: NSDictionary *_txtRecord; jens@28: MYBonjourQuery *_txtQuery; jens@28: MYAddressLookup *_addressLookup; jens@26: } jens@26: jens@59: /** The browser I belong to. */ jens@59: @property (readonly) MYBonjourBrowser *bonjourBrowser; jens@59: jens@26: /** The service's name. */ jens@26: @property (readonly) NSString *name; jens@26: jens@28: /** The service's type. */ jens@28: @property (readonly) NSString *type; jens@28: jens@28: /** The service's domain. */ jens@28: @property (readonly) NSString *domain; jens@28: jens@31: /** The service's full name -- the name, type and domain concatenated together. */ jens@31: @property (readonly,copy) NSString* fullName; jens@31: jens@31: /** The index of the network interface on which this service was found. */ jens@31: @property (readonly) uint32_t interfaceIndex; jens@31: jens@31: jens@31: /** @name Addressing jens@31: * Getting the IP address of the service jens@31: */ jens@31: //@{ jens@31: jens@31: /** The hostname of the machine providing this service. */ jens@28: @property (readonly, copy) NSString *hostname; jens@28: jens@31: /** The IP port number of this service on its host. */ jens@28: @property (readonly) UInt16 port; jens@28: jens@31: /** Returns a MYDNSLookup object that resolves the raw IP address(es) of this service. jens@31: Subsequent calls to this method will always return the same object. */ jens@31: - (MYAddressLookup*) addressLookup; jens@28: jens@31: //@} jens@31: jens@31: jens@31: /** @name TXT and other DNS records jens@31: */ jens@31: //@{ jens@28: jens@26: /** The service's metadata dictionary, from its DNS TXT record */ jens@26: @property (readonly,copy) NSDictionary *txtRecord; jens@26: jens@26: /** A convenience to access a single property from the TXT record. */ jens@26: - (NSString*) txtStringForKey: (NSString*)key; jens@26: jens@28: /** Starts a new MYBonjourQuery for the specified DNS record type of this service. jens@28: @param recordType The DNS record type, e.g. kDNSServiceType_TXT; see the enum in . */ jens@28: - (MYBonjourQuery*) queryForRecord: (UInt16)recordType; jens@26: jens@31: //@} jens@26: jens@26: jens@31: /** @name Protected jens@31: * Advanced methods that may be overridden by subclasses, but should not be called directly. jens@31: */ jens@31: //@{ jens@31: jens@31: /** Designated initializer. You probably don't want to create MYBonjourService instances yourself, jens@31: but if you subclass you might need to override this initializer. */ jens@59: - (id) initWithBrowser: (MYBonjourBrowser*)browser jens@59: name: (NSString*)serviceName jens@59: type: (NSString*)type jens@59: domain: (NSString*)domain jens@59: interface: (UInt32)interfaceIndex; jens@26: jens@31: /** Called when this service is officially added to its browser's service set. jens@31: You can override this, but be sure to call the superclass method. */ jens@26: - (void) added; jens@31: jens@31: /** Called when this service is officially removed to its browser's service set. jens@31: You can override this, but be sure to call the superclass method. */ jens@26: - (void) removed; jens@31: jens@31: /** Called when this service's TXT record changes. jens@31: You can override this, but be sure to call the superclass method. */ jens@26: - (void) txtRecordChanged; jens@26: jens@31: /** Called when a query started by this service updates. jens@31: You can override this, but be sure to call the superclass method. */ jens@28: - (void) queryDidUpdate: (MYBonjourQuery*)query; jens@28: jens@31: //@} jens@26: jens@26: @end