Implementation of a JSON-RPC client.
Implementation of a JSON-RPC server.
Standard error codes.
Create a BatchRequest to pass to an RPCClient's batch function.
Deserialize a JSON Object to the specified aggregate D type.
Execute an RPC method and return the server's response.
Handles all of an individual client's requests.
Serialize a struct to a JSON Object.
An RPC request constructed by the client to send to the RPC server.
The RPC server's response sent to clients.
1 enum hostname = "127.0.0.1"; 2 enum ushort port = 54321; 3 4 interface API { 5 long add(int a, int b); 6 } 7 8 class ServeFunctions { 9 long add(int a, int b) { return a + b; } 10 } 11 12 void main(string[] args) 13 { 14 import core.thread : Thread; 15 import core.time : dur; 16 17 auto t = new Thread({ 18 auto rpc = new RPCServer!ServeFunctions(hostname, port); 19 rpc.listen(); 20 }); 21 t.isDaemon = true; 22 t.start(); 23 Thread.sleep(dur!"seconds"(2)); 24 25 auto client = new RPCClient!API(hostname, port); 26 assert(client.add(2, 2) == 4); 27 assert(client.add(5, 6) == 11); 28 }
MIT
Copyright 2018 Ryan Frame
JSON-RPC 2.0 protocol library.
The JSON-RPC 2.0 specification may be found at http://www.jsonrpc.org/specification