batchReq

Create a BatchRequest to pass to an RPCClient's batch function.

batchReq
(
string method
,
JSONValue params
,
Flag!"notify" notify = No.notify
)

Parameters

method
Type: string

The name of the remote method to call.

params
Type: JSONValue

A JSONValue scalar or object/array containing the method parameters.

notify
Type: Flag!"notify"

Yes.notify if the request is a notification; No.notify otherwise.

Return Value

Type: auto

A BatchRequest to be passed to an RPCClient's batch function.

Examples

1 import std.typecons : Yes;
2 
3 interface API {
4     void func1(int a);
5     long func2(string s);
6     long func3();
7 }
8 auto client = RPCClient!API("localhost", 54321);
9 
10 auto responses = client.batch(
11         batchReq("func1", JSONValue(50)),
12         batchReq("func1", JSONValue(-1), Yes.notify),
13         batchReq("func2", JSONValue("hello")),
14         batchReq("func3", JSONValue(), Yes.notify),
15         batchReq("func1", JSONValue(123))
16 );

Meta