Bonjour/MYBonjourService.h
author Jens Alfke <jens@mooseyard.com>
Mon Jul 20 14:50:49 2009 -0700 (2009-07-20)
changeset 60 dd637bdd214e
parent 50 63baa74c903f
permissions -rw-r--r--
DNS NULL record support in MYBonjourRegistration. Minor fix to IPAddress init. Force 4-char indent in source files.
jens@26
     1
//
jens@26
     2
//  MYBonjourService.h
jens@26
     3
//  MYNetwork
jens@26
     4
//
jens@26
     5
//  Created by Jens Alfke on 1/22/08.
jens@26
     6
//  Copyright 2008 Jens Alfke. All rights reserved.
jens@26
     7
//
jens@26
     8
jens@28
     9
#import "MYDNSService.h"
jens@59
    10
@class MYBonjourBrowser, MYBonjourQuery, MYAddressLookup;
jens@26
    11
jens@26
    12
jens@50
    13
/** Represents a Bonjour service discovered by a MYBonjourBrowser. */
jens@28
    14
@interface MYBonjourService : MYDNSService 
jens@26
    15
{
jens@26
    16
    @private
jens@59
    17
    MYBonjourBrowser *_bonjourBrowser;
jens@28
    18
    NSString *_name, *_fullName, *_type, *_domain, *_hostname;
jens@28
    19
    uint32_t _interfaceIndex;
jens@28
    20
    BOOL _startedResolve;
jens@28
    21
    UInt16 _port;
jens@26
    22
    NSDictionary *_txtRecord;
jens@28
    23
    MYBonjourQuery *_txtQuery;
jens@28
    24
    MYAddressLookup *_addressLookup;
jens@26
    25
}
jens@26
    26
jens@59
    27
/** The browser I belong to. */
jens@59
    28
@property (readonly) MYBonjourBrowser *bonjourBrowser;
jens@59
    29
jens@26
    30
/** The service's name. */
jens@26
    31
@property (readonly) NSString *name;
jens@26
    32
jens@28
    33
/** The service's type. */
jens@28
    34
@property (readonly) NSString *type;
jens@28
    35
jens@28
    36
/** The service's domain. */
jens@28
    37
@property (readonly) NSString *domain;
jens@28
    38
jens@31
    39
/** The service's full name -- the name, type and domain concatenated together. */
jens@31
    40
@property (readonly,copy) NSString* fullName;
jens@31
    41
jens@31
    42
/** The index of the network interface on which this service was found. */
jens@31
    43
@property (readonly) uint32_t interfaceIndex;
jens@31
    44
jens@31
    45
jens@31
    46
/** @name Addressing
jens@31
    47
 *  Getting the IP address of the service
jens@31
    48
 */
jens@31
    49
//@{
jens@31
    50
jens@31
    51
/** The hostname of the machine providing this service. */
jens@28
    52
@property (readonly, copy) NSString *hostname;
jens@28
    53
jens@31
    54
/** The IP port number of this service on its host. */
jens@28
    55
@property (readonly) UInt16 port;
jens@28
    56
jens@31
    57
/** Returns a MYDNSLookup object that resolves the raw IP address(es) of this service.
jens@31
    58
    Subsequent calls to this method will always return the same object. */
jens@31
    59
- (MYAddressLookup*) addressLookup;
jens@28
    60
jens@31
    61
//@}
jens@31
    62
jens@31
    63
jens@31
    64
/** @name TXT and other DNS records
jens@31
    65
 */
jens@31
    66
//@{
jens@28
    67
jens@26
    68
/** The service's metadata dictionary, from its DNS TXT record */
jens@26
    69
@property (readonly,copy) NSDictionary *txtRecord;
jens@26
    70
jens@26
    71
/** A convenience to access a single property from the TXT record. */
jens@26
    72
- (NSString*) txtStringForKey: (NSString*)key;
jens@26
    73
jens@28
    74
/** Starts a new MYBonjourQuery for the specified DNS record type of this service.
jens@28
    75
    @param recordType  The DNS record type, e.g. kDNSServiceType_TXT; see the enum in <dns_sd.h>. */
jens@28
    76
- (MYBonjourQuery*) queryForRecord: (UInt16)recordType;
jens@26
    77
jens@31
    78
//@}
jens@26
    79
jens@26
    80
jens@31
    81
/** @name Protected
jens@31
    82
 *  Advanced methods that may be overridden by subclasses, but should not be called directly.
jens@31
    83
 */
jens@31
    84
//@{
jens@31
    85
jens@31
    86
/** Designated initializer. You probably don't want to create MYBonjourService instances yourself,
jens@31
    87
    but if you subclass you might need to override this initializer. */
jens@59
    88
- (id) initWithBrowser: (MYBonjourBrowser*)browser
jens@59
    89
                  name: (NSString*)serviceName
jens@59
    90
                  type: (NSString*)type
jens@59
    91
                domain: (NSString*)domain
jens@59
    92
             interface: (UInt32)interfaceIndex;
jens@26
    93
jens@31
    94
/** Called when this service is officially added to its browser's service set.
jens@31
    95
    You can override this, but be sure to call the superclass method. */
jens@26
    96
- (void) added;
jens@31
    97
jens@31
    98
/** Called when this service is officially removed to its browser's service set.
jens@31
    99
    You can override this, but be sure to call the superclass method. */
jens@26
   100
- (void) removed;
jens@31
   101
jens@31
   102
/** Called when this service's TXT record changes.
jens@31
   103
    You can override this, but be sure to call the superclass method. */
jens@26
   104
- (void) txtRecordChanged;
jens@26
   105
jens@31
   106
/** Called when a query started by this service updates.
jens@31
   107
    You can override this, but be sure to call the superclass method. */
jens@28
   108
- (void) queryDidUpdate: (MYBonjourQuery*)query;
jens@28
   109
jens@31
   110
//@}
jens@26
   111
jens@26
   112
@end