Bonjour/MYBonjourRegistration.h
changeset 34 1fadc382ece2
child 59 46c7844cb592
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Bonjour/MYBonjourRegistration.h	Mon May 04 23:10:51 2009 -0700
     1.3 @@ -0,0 +1,81 @@
     1.4 +//
     1.5 +//  MYBonjourRegistration.h
     1.6 +//  MYNetwork
     1.7 +//
     1.8 +//  Created by Jens Alfke on 4/27/09.
     1.9 +//  Copyright 2009 Jens Alfke. All rights reserved.
    1.10 +//
    1.11 +
    1.12 +#import "MYDNSService.h"
    1.13 +@class MYBonjourService;
    1.14 +
    1.15 +
    1.16 +/** Registers a local network service with Bonjour, so it can be browsed by other computers. */
    1.17 +@interface MYBonjourRegistration : MYDNSService
    1.18 +{
    1.19 +    NSString *_name, *_type, *_domain;
    1.20 +    UInt16 _port;
    1.21 +    BOOL _autoRename;
    1.22 +    BOOL _registered;
    1.23 +    NSMutableDictionary *_txtRecord;
    1.24 +}
    1.25 +
    1.26 +/** Initializes a new registration.
    1.27 +    If you're also browsing for the same service type, you should instead get an instance of this via
    1.28 +    the MYBonjourBrowser's 'myRegistration' property -- that way the browser knows about the
    1.29 +    registration and won't echo it back to you.
    1.30 +    Either way, don't forget to call -start! */
    1.31 +- (id) initWithServiceType: (NSString*)serviceType port: (UInt16)port;
    1.32 +
    1.33 +/** The name to register this service under.
    1.34 +    This is often left nil, in which case the user's chosen "Computer Name" (from the Sharing system
    1.35 +    pref pane) will be used.
    1.36 +    This can only be set before calling -start! */
    1.37 +@property (copy) NSString *name;
    1.38 +
    1.39 +/** The registration's service type. */
    1.40 +@property (readonly) NSString *type;
    1.41 +
    1.42 +/** The registration's IP port number.
    1.43 +    You'll need to set this if you got this object from MYBonjourBrowser's 'myRegistration' property,
    1.44 +    as that object doesn't have a pre-set port number yet.
    1.45 +    This can only be set before calling -start!  */
    1.46 +@property UInt16 port;
    1.47 +
    1.48 +/** The registration's full name -- the name, type and domain concatenated together. */
    1.49 +@property (readonly) NSString *fullName;
    1.50 +
    1.51 +/** Is the registration currently active? */
    1.52 +@property (readonly) BOOL registered;
    1.53 +
    1.54 +/** The service's metadata dictionary, stored in its DNS TXT record */
    1.55 +@property (copy) NSDictionary *txtRecord;
    1.56 +
    1.57 +/** Convenience to store a string value in a single TXT record key. */
    1.58 +- (void) setString: (NSString*)value forTxtKey: (NSString*)key;
    1.59 +
    1.60 +
    1.61 +/** @name Expert
    1.62 + *  Advanced methods you likely won't need
    1.63 + */
    1.64 +//@{
    1.65 +
    1.66 +/** The registration's domain name.
    1.67 +    This is almost always left nil, in which case the default registration domain is used
    1.68 +    (usually ".local".)
    1.69 +    This can only be set before calling -start!  */
    1.70 +@property (copy) NSString *domain;
    1.71 +
    1.72 +/** Determines what to do if there's a name conflict with an already-registered service on the
    1.73 +    network.
    1.74 +    If set to YES (the default), a number will be appended to the name to make it unique.
    1.75 +    If set to NO, the registration will fail, and you can choose a different name and try again.
    1.76 +    This can only be set before calling -start!  */
    1.77 +@property BOOL autoRename;
    1.78 +
    1.79 +/** Is this browsed service an echo of this local registration? (Compares fullNames.) */
    1.80 +- (BOOL) isSameAsService: (MYBonjourService*)service;
    1.81 +
    1.82 +//@}
    1.83 +
    1.84 +@end