JSONRPCResponseHandler Class Reference

an intermediate object returned by the JSONRPCService when you call a method, to help you define how to handle the response. More...

#import <JSONRPCResponseHandler.h>

List of all members.

Public Member Functions

(void) - setDelegate:callback:
 set both the delegate and the callback to call upon receiving the WebService's response
(void) - setDelegate:callback:resultClass:
 set both the delegate, the callback and the resultClass at once.
(void) - retryRequest
 Relaunch the request associated with this responseHandler. You should not need to call this method yourself as this is done automatically upon network error.

Properties

JSONRPCMethodCallmethodCall
 the method call attached with this response handler
id< NSObject > delegate
 The delegate object on which the callback will be called.
SEL callback
 The callback (@selector) to call when receiving the response from the WebService.
Class resultClass
int maxRetryAttempts
NSTimeInterval delayBeforeRetry

Detailed Description

an intermediate object returned by the JSONRPCService when you call a method, to help you define how to handle the response.

JSONRPCResponseHandler is an intermediate object used to define a delegate and a callback (= a target and an action) to call when the WebService's response is received, and the Objective-C class to use if you want the received JSON object to be converted to a custom Obj-C object automatically before calling the callback.

You typically don't create a JSONRPCResponseHandler yourself. Instead, you retreive such objects when calling callMethod: (JSONRPCService) or similar methods; this returned object help you define how to handle the response returned by the WebService after the method call.


Member Function Documentation

- (void) setDelegate: (id<NSObject>)  aDelegate
callback: (SEL)  callback 

set both the delegate and the callback to call upon receiving the WebService's response

Parameters:
aDelegate the delegate object that will receive the message (on which the callback will be called)
callback the @selector to call (the message to send onto the delegate)
- (void) setDelegate: (id<NSObject>)  aDelegate
callback: (SEL)  callback
resultClass: (Class)  cls 

set both the delegate, the callback and the resultClass at once.

Parameters:
aDelegate the delegate object that will receive the message (on which the callback will be called)
callback the @selector to call (the message to send onto the delegate)
cls the Class to convert the received JSON object to before calling the callback.
Note:
this method is typically useful when you nest it directly with the call of the JSONRPCMethodCall (JSONRPCService::callMethod or similar), as doing it that way you avoid the need to declare a temporary JSONRPCResponseHandler
 [[service callMethod:xxx] setDelegate:d callback:@selector(methodCall:didReturn:error:) resultClass:[MyCustomObject class]] 

Property Documentation

- (SEL) callback [read, write, assign]

The callback (@selector) to call when receiving the response from the WebService.

This @selector must take three parameters:

  • a JSONRPCMethodCall representing the method call that triggered the response
  • a parameter of type 'id' or of a specific class corresponding to the expected response returned by the WebService. If you define a resultClass on the JSONRPCResponseHandler, the type of this second argument of the @selector is typically the same class.
  • a parameter of type NSError that will hold the error returned by the WebService if any.
Note:
This method is called on the JSONRPCResponseHandler::delegate object if set, or on the JSONRPCService::delegate if not.
By default, this selector is not set (the default) and the JSONRPCDelegate methodCall:didReturn:error: (JSONRPCDelegate @protocol) method is called instead.
- (id<NSObject>) delegate [read, write, retain]

The delegate object on which the callback will be called.

Note:
If this delegate is nil (the default), the JSONRPCService::delegate is used instead.
- (Class) resultClass [read, write, assign]

The class to convert the received object to, if wanted. If this @property is not nil, the received JSON object will be converted to an instance of the given class before calling the callback @selector. The provided class must conform to the JSONInitializer informal protocol, i.e. it must respond to -initWithJson: .

Note:
if the WebService's JSON response is an NSArray (the root JSON object is an array), then instead every object in the array will be converted to the provided class. (instead of trying to create the instance of this class by passing the NSArray to initWithJson: directly)
Generated on Tue Mar 22 22:27:19 2011 for JSONRPC Framework by  doxygen 1.6.3