Project DescriptionJSON-RPC.Net is a high performance Json-Rpc 2.0 server, leveraging the popular JSON.NET library. The server communicates easily with JavaScript clients and works with the Jquery JsonRpc2 plugin, and includes support for JSONP.
The source also includes a client library built on Reactive Extensions to support .NET and Silverlight clients. There is also source for an early Windows Phone 7 client (it needs unit tests).
The Json-Rpc server allows asmx style setup and configuration.
There are some simple test client and server projects. With the test server started, then the Test client should pass all its tests.
Some simple performance test results running client and server locally
does not include network latency.
Metrics were recorded client side, so a "request" is a request and response from the server, including serialization.
Pass0 - 50 requests in : 39ms for 1282 requests per second
Pass1 - 100 requests in : 57ms for 1754 requests per second
Pass2 - 200 requests in : 90ms for 2222 requests per second
Pass3 - 400 requests in : 159ms for 2515 requests per second
Pass4 - 800 requests in : 352ms for 2272 requests per second
Pass5 - 1600 requests in : 712ms for 2247 requests per second
Pass6 - 3200 requests in : 1416ms for 2259 requests per second
- Built with Visual Studio 2010, Source Code is in C# **
Get Started
DocumentationServer SideHello World service
namespace TestServer{
using System;
using AustinHarris.JsonRpc;
public class HelloWorldService: JsonRpcService{
[JsonRpcMethod]
private string helloWorld(string message){
return "Hello World "+ message;
}
}
}
Hello World service registration (Global.asax.cs)
using System;
namespace JsonRpcTest{
public class Global : System.Web.HttpApplication {
private static HelloWorldService service = new HelloWorldService();
}
}
Json-Rpc handler setup (web.config in an asp.net project)
<?xml version="1.0"?>
<configuration>
<system.web>
<httpHandlers>
<add type="AustinHarris.JsonRpc.JsonRpcHandler" verb="*" path="*.rpc"/>
</httpHandlers>
</system.web>
</configuration>
Client Side
public void TestHelloWorld() {
var client = new AustinHarris.JsonRpc.JsonRpcClient(new Uri("http://localhost:57956/json.rpc"));
var myObs = client.Invoke<string>("helloWorld", "My Message", Scheduler.TaskPool);
myObs.Subscribe(
onNext: _ => {
Console.WriteLine(_.Result);
});
}
JsonRpcClient.Invoke has the signature:
public IObservable<JsonResponse<T>> Invoke<T>(string method, object arg, IScheduler scheduler)
So that when you call it, it follows this format:
Invoke<ReturnType>("RpcMethodName",RpcParameter, ConcurrencyScheduler)