batchReq

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

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

Parameters

method string

The name of the remote method to call.

params JSONValue

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

notify 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

import std.typecons : Yes;

interface API {
    void func1(int a);
    long func2(string s);
    long func3();
}
auto client = RPCClient!API("localhost", 54321);

auto responses = client.batch(
        batchReq("func1", JSONValue(50)),
        batchReq("func1", JSONValue(-1), Yes.notify),
        batchReq("func2", JSONValue("hello")),
        batchReq("func3", JSONValue(), Yes.notify),
        batchReq("func1", JSONValue(123))
);

Meta