Project Description
JSON-RPC.Net is a high performance Json-Rpc 2.0 server, leveraging the popular JSON.NET library. Host in ASP.NET, also supports sockets and pipes, oh my!
[Dot Net 4.0|Mono] currently Required. ASP.Net is optional.
New in release 1.0.3
Performance under ideal conditions > 120k rpc/sec (cpu i7-2600,console server, no IO bottleneck)
Get Started Documentation
NuGet Install
To install JSON-RPC.NET Core, run the following command in the Package Manager Console
To install JSON-RPC.NET AspNet, run the following command in the Package Manager Console
Service Setup:
public class CalculatorService : JsonRpcService
{
[JsonRpcMethod]
private double add(double l, double r)
{
return l+r;
}
}
Console Hosting: Registering CalculatorService
namespace Server_Console
{
class Program
{
static object[] services = new object[] {
new CalculatorService()
};
...
}
}
Console Hosting: Processing
namespace Server_Console
{
class Program
{
...
static void Main(string[] args)
{
var rpcResultHandler = new AsyncCallback(_ => Console.WriteLine(((JsonRpcStateAsync)_).Result));
for (string line = Console.ReadLine(); !string.IsNullOrEmpty(line); line = Console.ReadLine())
{
var async = new JsonRpcStateAsync(rpcResultHandler, null);
async.JsonRpc = line;
JsonRpcProcessor.Process(async);
}
}
}

ASP.NET: Hello World service
namespace TestServer{
using System;
using AustinHarris.JsonRpc;
public class HelloWorldService: JsonRpcService{
[JsonRpcMethod]
private string helloWorld(string message){
return "Hello World "+ message;
}
}
}
ASP.NET: Hello World service registration (Global.asax.cs)
using System;
namespace JsonRpcTest{
public class Global : System.Web.HttpApplication {
private static HelloWorldService service = new HelloWorldService();
}
}
ASP.NET: Processing Json-Rpc handler setup (web.config in an asp.net project)
<?xml version="1.0"?>
<configuration>
<system.web>
<httpHandlers>
<add type="AustinHarris.JsonRpc.Handlers.AspNet.JsonRpcHandler" verb="*" path="*.rpc"/>
</httpHandlers>
</system.web>
</configuration>
ASP.NET Handler supports GET and POST via raw OR form-urlencoded
