* Fixed: Responses still pending when a connection closed were not calling their onComplete targets.
* Fixed: BLIPTestClient target failed to build because it didn't link against zlib.
* If TCPListener.bonjourServiceName is changed while the listener is open, it now re-publishes the service with the new name.
* Added a TCPListener.bonjourService property.
* Added a BLIPMessage.representedObject property.
* Fixed a memory leak.
5 // Created by Jens Alfke on 5/15/08.
6 // Copyright 2008 Jens Alfke. All rights reserved.
9 #import <Foundation/Foundation.h>
10 @class MYTarget, BLIPMessage;
13 /** Routes BLIP messages to targets based on a series of rules.
15 Every BLIPConnection has a BLIPDispatcher, which is initially empty, but you can add rules
18 Every BLIPListener also has a dispatcher, which is inherited as the parent by every
19 connection that it accepts, so you can add rules to the listener's dispatcher to share them
20 between all connections.
22 It's not necessary to use a dispatcher. Any undispatched requests will be sent to the
23 BLIPConnection's delegate's -connection:receivedRequest: method, which can do its own
24 custom handling. But it's often easier to use the dispatcher to associate handlers with
25 request based on property values. */
26 @interface BLIPDispatcher : NSObject
28 NSMutableArray *_predicates, *_targets;
29 BLIPDispatcher *_parent;
32 /** The inherited parent dispatcher.
33 If a message does not match any of this dispatcher's rules, it will next be passed to
34 the parent, if there is one. */
35 @property (retain) BLIPDispatcher *parent;
37 /** Convenience method that adds a rule that compares a property against a string. */
38 - (void) addTarget: (MYTarget*)target forValueOfProperty: (NSString*)value forKey: (NSString*)key;
40 #if ! TARGET_OS_IPHONE /* NSPredicate is not available on iPhone, unfortunately */
41 /** Adds a new rule, to call a given target method if a given predicate matches the message. */
42 - (void) addTarget: (MYTarget*)target forPredicate: (NSPredicate*)predicate;
45 /** Removes all rules with the given target method. */
46 - (void) removeTarget: (MYTarget*)target;
48 /** Tests the message against all the rules, in the order they were added, and calls the
49 target of the first matching rule.
50 If no rule matches, the message is passed to the parent dispatcher's -dispatchMessage:,
52 If no rules at all match, NO is returned. */
53 - (BOOL) dispatchMessage: (BLIPMessage*)message;
55 /** Returns a target object that will call this dispatcher's -dispatchMessage: method.
56 This can be used to make this dispatcher the target of another dispatcher's rule,
57 stringing them together hierarchically. */
58 - (MYTarget*) asTarget;