jens@31: // jens@31: // MYBonjourRegistration.h jens@31: // MYNetwork jens@31: // jens@31: // Created by Jens Alfke on 4/27/09. jens@31: // Copyright 2009 Jens Alfke. All rights reserved. jens@31: // jens@31: jens@31: #import "MYDNSService.h" jens@31: @class MYBonjourService; jens@31: jens@31: jens@31: /** Registers a local network service with Bonjour, so it can be browsed by other computers. */ jens@31: @interface MYBonjourRegistration : MYDNSService jens@31: { jens@31: NSString *_name, *_type, *_domain; jens@31: UInt16 _port; jens@31: BOOL _autoRename; jens@31: BOOL _registered; jens@31: NSMutableDictionary *_txtRecord; jens@31: } jens@31: jens@31: /** Initializes a new registration. jens@31: If you're also browsing for the same service type, you should instead get an instance of this via jens@31: the MYBonjourBrowser's 'myRegistration' property -- that way the browser knows about the jens@31: registration and won't echo it back to you. jens@31: Either way, don't forget to call -start! */ jens@31: - (id) initWithServiceType: (NSString*)serviceType port: (UInt16)port; jens@31: jens@31: /** The name to register this service under. jens@31: This is often left nil, in which case the user's chosen "Computer Name" (from the Sharing system jens@31: pref pane) will be used. jens@31: This can only be set before calling -start! */ jens@31: @property (copy) NSString *name; jens@31: jens@31: /** The registration's service type. */ jens@31: @property (readonly) NSString *type; jens@31: jens@31: /** The registration's IP port number. jens@31: You'll need to set this if you got this object from MYBonjourBrowser's 'myRegistration' property, jens@31: as that object doesn't have a pre-set port number yet. jens@31: This can only be set before calling -start! */ jens@31: @property UInt16 port; jens@31: jens@31: /** The registration's full name -- the name, type and domain concatenated together. */ jens@31: @property (readonly) NSString *fullName; jens@31: jens@31: /** Is the registration currently active? */ jens@31: @property (readonly) BOOL registered; jens@31: jens@31: /** The service's metadata dictionary, stored in its DNS TXT record */ jens@31: @property (copy) NSDictionary *txtRecord; jens@31: jens@31: /** Convenience to store a string value in a single TXT record key. */ jens@31: - (void) setString: (NSString*)value forTxtKey: (NSString*)key; jens@31: jens@31: jens@31: /** @name Expert jens@31: * Advanced methods you likely won't need jens@31: */ jens@31: //@{ jens@31: jens@31: /** The registration's domain name. jens@31: This is almost always left nil, in which case the default registration domain is used jens@31: (usually ".local".) jens@31: This can only be set before calling -start! */ jens@31: @property (copy) NSString *domain; jens@31: jens@31: /** Determines what to do if there's a name conflict with an already-registered service on the jens@31: network. jens@31: If set to YES (the default), a number will be appended to the name to make it unique. jens@31: If set to NO, the registration will fail, and you can choose a different name and try again. jens@31: This can only be set before calling -start! */ jens@31: @property BOOL autoRename; jens@31: jens@31: /** Is this browsed service an echo of this local registration? (Compares fullNames.) */ jens@31: - (BOOL) isSameAsService: (MYBonjourService*)service; jens@31: jens@31: //@} jens@31: jens@31: @end