- Notifications
You must be signed in to change notification settings - Fork 86
Getting Started (Console)
Austin Harris edited this page Sep 22, 2020
·
4 revisions
Using json-rpc.net within a console application;
- Create a console application
- Install Json-Rpc.Net Core using NuGet
Create a JsonRpcService
publicclassExampleCalculatorService:JsonRpcService{[JsonRpcMethod]privatedoubleadd(doublel,doubler){returnl+r;}}Register that service before it will ever be used
namespaceExample{classConsoleServer{staticobject[]services=newobject[]{newExampleCalculatorService()};}}Direct input from the console to the JsonRpc Processor and pass the output back to the console
asyncstaticvoidMain(string[]args){for(stringline=Console.ReadLine();!string.IsNullOrEmpty(line);line=Console.ReadLine()){varresponse=awaitJsonRpcProcessor.Process(line);Console.WriteLine(response.Result);}}