An Objective-C native implementation of dnode asynchronous RPC protocol for iOS and OSX. It uses the following library


Start by subclassing DNode and define your local dnode interface in a header file.

#import "DNode.h"

@interface TestClient : DNode
-(void)foo; //the method your would like to call on remote

To expose your local dnode interface to the remote, use C++ macro DEFINE_CLIENT_METHOD(local_name). For example

//the direct call from remote dnode
    NSLog(@"hello from server: %@ ", args); 

To explicitly declare a method on remote and receive callback, use DEFINE_SERVER_METHOD_WITH_CALLBACK(remote_name)

//the callback from a previous local-to-remote call
    NSLog(@"callback from server %@", args);

To invoke a method on remote, use CALL_SERVER_METHOD(remote_name, arg) whose remote_name must match the name defined in DEFINE_SERVER_METHOD_WITH_CALLBACK. For example

    id arg = @[@"hello from client"];
    CALL_SERVER_METHOD(echo, arg);

To create a dnode instance and connect to a remote

TestClient* client = [[TestClient alloc] init];  
[client connectToHost:@"" Port:8000 Callback:^(BOOL success, NSNumber* err){
        NSLog(@"connected %d with err %@", success, err);

Set up a delegate object to get notified on connection status

[client addListener:self CallbackQueue:dispatch_get_main_queue()];

A number of delegate callbacks are

-(void)connectSuccess; //connected to remote
-(void)remoteReady; //remote interface ready

For details please look into the test directory for OSX and iOS demo projects.

Todo List

  • local listening server that receives remote connection
  • callback to remote from a previous remote-to-local invocation
  • more unit testing and examples

Source Code