This project is read-only.

Recieving requests

You can register callbacs for remote method requests or notifications.

Remote metod requests

In order to register for remote method, you need to specify delegate method, and register it using JsonRpcController's RegisterRemoteMethodExecutor method.


Delegate of method adding 2 integers together:

private async static Task<MethodResponse> OnSum(Object sumParams)
	var response = new MethodResponse();
		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;

Registering method

networkManager.RegisterRemoteMethodExecutor("sum", OnSum);

Remote notifications

Registering for notification is similar to remote method requests, besides delegate functions don't return anything.


Delegate of ping notification:

private async void OnPing(Object pingParams)
	Log("Recieved ping!");

Registering notification

networkManager.RegisterRemoteNotificationExecutor("ping", OnPing);

Last edited Dec 3, 2012 at 10:58 PM by axadiw, version 5


No comments yet.