author | Jens Alfke <jens@mooseyard.com> |
Wed Apr 22 16:45:39 2009 -0700 (2009-04-22) | |
changeset 26 | cb9cdf247239 |
child 28 | 732576fa8a0d |
permissions | -rw-r--r-- |
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@26 | 9 |
#import <Foundation/Foundation.h> |
jens@26 | 10 |
#import "ConcurrentOperation.h" |
jens@26 | 11 |
@class MYBonjourResolveOperation; |
jens@26 | 12 |
|
jens@26 | 13 |
|
jens@26 | 14 |
/** Represents a Bonjour service discovered by a BonjourBrowser. */ |
jens@26 | 15 |
@interface MYBonjourService : NSObject |
jens@26 | 16 |
{ |
jens@26 | 17 |
@private |
jens@26 | 18 |
NSNetService *_netService; |
jens@26 | 19 |
NSDictionary *_txtRecord; |
jens@26 | 20 |
NSSet *_addresses; |
jens@26 | 21 |
CFAbsoluteTime _addressesExpireAt; |
jens@26 | 22 |
MYBonjourResolveOperation *_resolveOp; |
jens@26 | 23 |
} |
jens@26 | 24 |
|
jens@26 | 25 |
/** The service's name. */ |
jens@26 | 26 |
@property (readonly) NSString *name; |
jens@26 | 27 |
|
jens@26 | 28 |
/** The service's metadata dictionary, from its DNS TXT record */ |
jens@26 | 29 |
@property (readonly,copy) NSDictionary *txtRecord; |
jens@26 | 30 |
|
jens@26 | 31 |
/** A convenience to access a single property from the TXT record. */ |
jens@26 | 32 |
- (NSString*) txtStringForKey: (NSString*)key; |
jens@26 | 33 |
|
jens@26 | 34 |
/** Returns a set of IPAddress objects; may be the empty set if address resolution failed, |
jens@26 | 35 |
or nil if addresses have not been resolved yet (or expired). |
jens@26 | 36 |
In the latter case, call -resolve and wait for the returned Operation to finish. */ |
jens@26 | 37 |
@property (readonly,copy) NSSet* addresses; |
jens@26 | 38 |
|
jens@26 | 39 |
/** Starts looking up the IP address(es) of this service. |
jens@26 | 40 |
@return The NSOperation representing the lookup; you can observe this to see when it |
jens@26 | 41 |
completes, or you can observe the service's 'addresses' property. */ |
jens@26 | 42 |
- (MYBonjourResolveOperation*) resolve; |
jens@26 | 43 |
|
jens@26 | 44 |
/** The underlying NSNetSerice object. */ |
jens@26 | 45 |
@property (readonly) NSNetService *netService; |
jens@26 | 46 |
|
jens@26 | 47 |
|
jens@26 | 48 |
// Protected methods, for subclass use only: |
jens@26 | 49 |
|
jens@26 | 50 |
- (id) initWithNetService: (NSNetService*)netService; |
jens@26 | 51 |
|
jens@26 | 52 |
// (for subclasses to override, but not call): |
jens@26 | 53 |
- (void) added; |
jens@26 | 54 |
- (void) removed; |
jens@26 | 55 |
- (void) txtRecordChanged; |
jens@26 | 56 |
|
jens@26 | 57 |
@end |
jens@26 | 58 |
|
jens@26 | 59 |
|
jens@26 | 60 |
|
jens@26 | 61 |
@interface MYBonjourResolveOperation : ConcurrentOperation |
jens@26 | 62 |
{ |
jens@26 | 63 |
MYBonjourService *_service; |
jens@26 | 64 |
NSSet *_addresses; |
jens@26 | 65 |
} |
jens@26 | 66 |
|
jens@26 | 67 |
@property (readonly) MYBonjourService *service; |
jens@26 | 68 |
@property (readonly,retain) NSSet *addresses; |
jens@26 | 69 |
|
jens@26 | 70 |
@end |