Overview

Briefely, you use this framework in four steps:

  1. Create a JSONRPCService object
  2. Call a remote procedure of the WebService using JSON-RPC
  3. Handle the response from the server
  4. Release the service
Note:
some useful macros to create arrays and dicts are defined in JSONRPC.h

Create a JSONRPCService object

You do this typically by passing the URL of the WebService to the init constructor, specifying the JSON-RPC version supported by the WebService:

 JSONRPCService* service = [[JSONRPCService alloc] initWithURL:kServiceURL version:JSONRPCVersion_1_0];

Call a remote procedure of the WebService using JSON-RPC

To do this, you have multiple equivalent possibilities:

Handle the response from the server

When you call a JSON-RPC method, you get a JSONRPCResponseHandler object as a return value.

Note that you can nest the JSONRPCService method call with the JSONRPCResponseHandler calls to be more concise:

   [[service callMethodWithNameAndParams:@"echo",@"Hello there",nil]
    setDelegate:self callback:@selector(methodCall:didReturn:error) resultClass:[MyCustomClass class]];

Release the service

Of course don't forget to release your JSONRPCService when you are done.

Note:
JSONRPCService objects are internally retained while a request has been sent to the service (and then automatically autoreleased when the request receive the response, avec forwarding the response to the delegate). This way, you are not required to retain the JSONRPCService instance until you get the response (otherwise this would have required for you to keep a reference on the JSONRPCService as an instance variable)

Going further

As you can see, the usage of this framework is highly flexible. You can call a JSON-RPC method using multiple different syntaxes, and you can also receive the response in the way you think it's the best suitable for your project, centralizing the responses on one object (the JSONRPCService::delegate) or on separate objects (JSONRPCResponseHandler::delegate) and calling a unique @selector method for handling the response of all your method calls, or a different @selector for each.

For more information, you can look at the Example.

Generated on Tue Mar 22 22:27:19 2011 for JSONRPC Framework by  doxygen 1.6.3