rpc 1.1.0

An RPC library


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

rpc

| Build Status |

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.

Authors:
  • Eliott Dumeix
Dependencies:
vibe-d:core, autointf, vibe-d:utils, vibe-d:data, vibe-d:http
Versions:
1.1.0 2018-Sep-06
~master 2018-Nov-16
Show all 2 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 10 downloads total

Score:
0.0
Short URL:
rpc.dub.pm