IDEV.JRPC is JSON-RPC library based on JSON-RPC.NET. It's provide server and client parts.
- dotnet 4.5.1
- Nlog >= 3.1.0
- ConsulClient >= 0.7.2
- Ninject >= 3.2.2 (optional: only for JRPC.Registry.Ninject)
- Microsoft.Owin.Host.HttpListener >= 3.0.1
Also Consul agent needed to work properly.
To install IDEV.JRPC Service, run the following command in the Package Manager Console:
PM> Install-Package JRPC.Service
To install IDEV.JRPC Client, run the following command in the Package Manager Console:
PM> Install-Package JRPC.Client
To install IDEV.JRPC Ninject Registry, run the following command in the Package Manager Console:
PM> Install-Package JRPC.Registry.Ninject
Add appSettings
section in App.config:
<configuration>
...
<appSettings>
<add key="ServicePort" value="12345" />
<add key="ServiceAddress" value="127.0.0.1" />
</appSettings>
...
</configuration>
public interface ISomeService {
string GetString();
}
public class SomeService : JRpcModule, ISomeService {
public string GetString() {
return "Result from service";
}
}
var consulClient = new ConsulClient();
var registry = new DefaultModulesRegistry();
registry.AddJRpcModule(new SomeService());
var svc = new JRpcService(registry, consulClient);
svc.Start();
Console.ReadLine();
svc.Stop();
Define Ninject module like this:
public class SomeNinjectModule : NinjectModule {
public override void Load() {
Bind<JRpcModule>().To<SomeService>();
Bind<IModulesRegistry>().To<NinjectModulesRegistry>();
Bind<IConsulClient>().To<ConsulClient>();
Bind<JRpcService>().ToSelf();
}
}
var kernel = new StandardKernel();
kernel.Load<SomeNinjectModule>();
var svc = kernel.Get<JRpcService>();
svc.Start();
Console.ReadLine();
svc.Stop();
var client = new JRpcClient("http://127.0.0.1:12345");
var proxy = client.GetProxy<ISomeService>("SomeService");
Console.WriteLine(proxy.GetString()); // Output is "Result from service"
IDEV.JRPC is licensed under The MIT License.