Json-RPC RT

Json-RPC RT implements bidirectional JSON-RPC 2.0 protocol.

Features

  • Sending / recieving method requests
  • Notifications support
  • Batching support
  • Using StreamSockets (TCP)

Download JSON-RPC RT from CodePlex or install using NuGet

Nuget install

Serializing

Json-RPC RT is using high-performance JSON.NET library for JSON serializing/deserializing

Examples

Performing remote method (logging into remote service):
var remoteLoginMethodHandler = new LoginHandler(networkManager);
string token = await remoteLoginMethodHandler.Login("example@gmail.com", "password");

Handling remote requests for "Sum" method, that is adding 2 integers:


// somewhere in initialize section
networkManager.RegisterRemoteMethodExecutor("Sum", OnSum);

private async static Task<MethodResponse> OnSum(Object sumParams)
{
	var response = new MethodResponse();
	try
	{
		response.Type = ResponseType.NormalResponse;

		response.Content = (int) ((JObject) sumParams)["a"] + (int) ((JObject) sumParams)["b"];
	}
	catch (Exception)
	{
		response.Type = ResponseType.ErrorResponse;

		response.Content = "Sum error";
	}

	return response;
}

For more examples see Documentation

Last edited Dec 4, 2012 at 8:32 AM by axadiw, version 16