rpc 1.1.0
An RPC library
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
rpc
An rpc library aimed to be protocol independent. It's based on automatic interface implementation.
It currently support:
- Json RPC 2.0
It use vibed as HTPP and TCP driver.
Quick start with dub
"dependencies": {
"rpc": "*"
}
Usage
Server:
import rpc.protocol.json;
import vibe.appmain;
interface ICalculator
{
int sum(int a, int b);
int mult(int a, int b);
}
class Calculator : ICalculator
{
int sum(int a, int b) { return a + b; }
int mult(int a, int b) { return a * b; }
}
shared static this()
{
auto server = new TCPJsonRPCServer!int(2000u);
server.registerInterface!ICalculator(new Calculator());
}
Client:
import std.stdio;
import rpc.protocol.json;
interface ICalculator
{
int sum(int a, int b);
int mult(int a, int b);
}
void main()
{
auto calc = new TCPJsonRPCAutoClient!ICalculator("127.0.0.1", 2000u);
writeln(calc.sum(1, 2));
// > {"jsonrpc": "2.0", "method": "sum", "params": [1, 2], "id": 1}
// < {"jsonrpc": "2.0", "result": 3, "id": 1}
writeln(calc.mult(5, 5));
// > {"jsonrpc": "2.0", "method": "mult", "params": [5, 5], "id": 2}
// < {"jsonrpc": "2.0", "result": 25, "id": 2}
}
See more in the examples folder.
- Registered by Eliott Dumeix
- 1.1.0 released 6 years ago
- boolangery/d-rpc
- MIT
- Authors:
- Dependencies:
- vibe-d:data, vibe-d:utils, vibe-d:core, autointf, vibe-d:http
- Versions:
-
1.1.0 2018-Sep-06 ~master 2019-Apr-11 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
49 downloads total
-
- Score:
- 0.0
- Short URL:
- rpc.dub.pm