基于.NET的高性能JSON-RPC框架实现。

Justin da357463ba Add property to enable or disable the compression content of http response. há 1 ano atrás
JsonRpcLite da357463ba Add property to enable or disable the compression content of http response. há 1 ano atrás
JsonRpcLite.Kcp 4d64c2a4e1 Update to .NET6 há 3 anos atrás
JsonRpcLite.Kestrel 4d64c2a4e1 Update to .NET6 há 3 anos atrás
TestClient 4d64c2a4e1 Update to .NET6 há 3 anos atrás
TestServer 4d64c2a4e1 Update to .NET6 há 3 anos atrás
jrl bdeca18d20 Update to .NET6 há 3 anos atrás
.gitignore d58440f7fc Output rpcexception result há 3 anos atrás
JsonRpcLite.sln d358db9a17 Add KCP engine for JsonRpcLite. há 3 anos atrás
README.md e2bc460b4c First commit. há 3 anos atrás

README.md

JsonRpcLite

JsonRpcLite

This is a simple JsonRpc server implementation written in C#, it's simple, but fast!

Features

  • High performance, faster than JSON-RPC.NET.
  • Lightweight design, only one dll file.
  • Build-in http server, support http, websocket and in-process.
  • Support use Kestrel to provide services on http and websocket.
  • Attributes support, support customize service name and method name.
  • SMD support.
  • Interface based mode for C# development.

Performance

Here we have a benchmark compare with JSON-RPC.NET.

i7-7700 @ 3.6GHz 64.0 GB
JsonRpcLite
Starting benchmark
processed 50 rpc in      0ms for         ∞ rpc/sec
processed 100 rpc in     0ms for         ∞ rpc/sec
processed 300 rpc in     0ms for         ∞ rpc/sec
processed 1,200 rpc in   2ms for         600,000.00 rpc/sec
processed 6,000 rpc in   12ms for        500,000.00 rpc/sec
processed 36,000 rpc in          77ms for        467,532.47 rpc/sec
processed 252,000 rpc in         581ms for       433,734.94 rpc/sec
Finished benchmark...
JSON-RPC.NET
Starting benchmark
processed 50 rpc in      0ms for         ∞ rpc/sec
processed 100 rpc in     0ms for         ∞ rpc/sec
processed 300 rpc in     0ms for         ∞ rpc/sec
processed 1,200 rpc in   2ms for         600,000.00 rpc/sec
processed 6,000 rpc in   28ms for        214,285.71 rpc/sec
processed 36,000 rpc in          88ms for        409,090.91 rpc/sec
processed 252,000 rpc in         640ms for       393,750.00 rpc/sec
Finished benchmark...

Usage

Define the service
    public interface ITestService
    {
        public string Hello(string name);

        public int Add(int a, int b);
    }
    
    public class TestService:ITestService
    {
        public string Hello(string name)
        { 
          ...
        }

        public int Add(int a, int b)
        {
          ...
        }
    }
For server
   //In server
   var server = new JsonRpcServer();
   server.RegisterService<ITestService>(new TestService());
   var serverEngine = new JsonRpcHttpServerEngine("http://127.0.0.1:8090/");
   server.UseEngine(serverEngine);
   server.Start();
For clinet
  //In client
  var client = new JsonRpcClient();
  var clientEngine = new JsonRpcHttpClientEngine("http://127.0.0.1:8090/");
  client.UseEngine(clientEngine);
  var proxy = client.CreateProxy<ITestService>("TestService");
  Console.WriteLine(proxy.Hello("World"));