Simple yet extensible synchronous JSON-RPC client
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example
Pod/Classes
.gitignore
.travis.yml
LICENSE
PCJSONRPC.podspec
README.md

README.md

PCJSONRPC

CI Status Version License Platform

Simple yet extensible synchronous JSON-RPC client.

It's simple. Maybe so simple that it probably is not feature complete or even spec compliant. But it works for real world projects.

It's extensible because easily subclassable. Redefine one or all of the methods used in the process.

It's synchronous because sometime we know what we want and we know what we do. And we certainly know not to invoke a remote method on the main thread, right?

Tests

To run the - far from complete - tests, clone the repo, and run pod install from the Example directory before opening PCJSONRPC.xcworkspace.

Or, in one easy step, in a terminal:

$ pod try PCJSONRPC

Installation

PCJSONRPC is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "PCJSONRPC"

Usage

#import <PCJSONRPC.h>

Create a JSON-RPC client

NSURL *url = [NSURL URLWithString:@"http://example.com/json-rpc"];
PCJSONRPC *jsonRPC = [[PCJSONRPC alloc] initWithURL:url];

Invoke a method

NSError *error;
NSString *hello = [jsonRPC invokeMethod:@"echo"
                         withParameters:@[@"World!"]
                                  error:&error];

Define a protocol

@protocol EchoService
- (id)echo:(id)params error:(NSError **)error;
@end

Create a proxy

id<EchoService> service =
    [jsonRPC proxyForProtocol:@protocol(EchoService)];

Invoke a method

hello = [service echo:@[@"World!"] error:&error];

Author

Pierre-David Bélanger, pierredavidbelanger@gmail.com

License

PCJSONRPC is available under the MIT license. See the LICENSE file for more info.