RPCClient.opDispatch

Make a blocking remote call with natural syntax.

Any method (not part of the RPC client itself) that is present in the remote API can be called as if it was a member of the RPC client, and that function call will be forwarded to the remote server.

More...
class RPCClient(API, Transport = TCPTransport)
ref
opDispatch
(
string apiFunc
ARGS...
)
(
ARGS args
)
if (
is(API == interface) &&
isTransport!Transport
)

Parameters

args ARGS

The arguments of the remote function to call.

Return Value

Type: auto ref

The return value of the function call.

Detailed Description

Template Parameters

apiFunc = The name of the fake method to dispatch. <BR> ARGS... = A list of parameter types.

Throws

InvalidArgument if the argument types do not match the remote interface. RPCErrorResponse if the server returns an error response. Inspect the exception payload for details.

Examples

interface RemoteFuncs {
    void func1();
    int func2(bool b, string s);
}

auto rpc = new RPCClient!RemoteFuncs("127.0.0.1", 54321);
rpc.func1();
int retval = rpc.func2(false, "hello");

Notes: If you want the full response from the server, use the call function instead.

Meta