Fixed: The -connection:failedToOpen: delegate method wasn't being called.
5 // Created by Jens Alfke on 5/22/08.
6 // Copyright 2008 Jens Alfke. All rights reserved.
9 #import "BLIPMessage.h"
10 @class BLIPResponse, MYTarget;
13 /** A Request, or initiating message, in the <a href=".#blipdesc">BLIP</a> protocol. */
14 @interface BLIPRequest : BLIPMessage
17 BLIPResponse *_response;
20 /** Creates an outgoing request.
22 The request is not associated with any BLIPConnection yet, so you must either set its
23 connection property before calling -send, or pass the request as a parameter to
24 -[BLIPConnection sendRequest:]. */
25 + (BLIPRequest*) requestWithBody: (NSData*)body;
27 /** Creates an outgoing request.
28 The body or properties may be nil.
29 The request is not associated with any BLIPConnection yet, so you must either set its
30 connection property before calling -send, or pass the request as a parameter to
31 -[BLIPConnection sendRequest:]. */
32 + (BLIPRequest*) requestWithBody: (NSData*)body
33 properties: (NSDictionary*)properties;
35 /** BLIPRequest extends the -connection property to be settable.
36 This allows a request to be created without a connection (i.e. before the connection is created).
37 It can later be sent by setting the connection property and calling -send. */
38 @property (retain) BLIPConnection *connection;
40 /** Sends this request over its connection.
41 (Actually, the connection queues it to be sent; this method always returns immediately.)
42 Its matching response object will be returned, or nil if the request couldn't be sent.
43 If this request has not been assigned to a connection, an exception will be raised. */
44 - (BLIPResponse*) send;
46 /** Does this request not need a response?
47 This property can only be set before sending the request. */
48 @property BOOL noReply;
50 /** Returns YES if you've replied to this request (by accessing its -response property.) */
51 @property (readonly) BOOL repliedTo;
53 /** The request's response. This can be accessed at any time, even before sending the request,
54 but the contents of the response won't be filled in until it arrives, of course. */
55 @property (readonly) BLIPResponse *response;
57 /** Call this when a request arrives, to indicate that you want to respond to it later.
58 It will prevent a default empty response from being sent upon return from the request handler. */
59 - (void) deferResponse;
61 /** Shortcut to respond to this request with the given data.
62 The contentType, if not nil, is stored in the "Content-Type" property. */
63 - (void) respondWithData: (NSData*)data contentType: (NSString*)contentType;
65 /** Shortcut to respond to this request with the given string (which will be encoded in UTF-8). */
66 - (void) respondWithString: (NSString*)string;
68 /** Shortcut to respond to this request with an error. */
69 - (void) respondWithError: (NSError*)error;
71 /** Shortcut to respond to this request with the given error code and message.
72 The BLIPErrorDomain is assumed. */
73 - (void) respondWithErrorCode: (int)code message: (NSString*)message; //, ... __attribute__ ((format (__NSString__, 2,3)));;
75 /** Shortcut to respond to this message with an error indicating that an exception occurred. */
76 - (void) respondWithException: (NSException*)exception;
83 /** A reply to a BLIPRequest, in the <a href=".#blipdesc">BLIP</a> protocol. */
84 @interface BLIPResponse : BLIPMessage
88 MYTarget *_onComplete;
91 /** Sends this response. */
94 /** The error returned by the peer, or nil if the response is successful. */
95 @property (retain) NSError* error;
97 /** Sets a target/action to be called when an incoming response is complete.
98 Use this on the response returned from -[BLIPRequest send], to be notified when the response is available. */
99 @property (retain) MYTarget *onComplete;