public static void On <T, TResult>(this RpcProcessor rpc, string method, Func <T, Task <TResult> > handler) { rpc.Register(method, async(sender, payload) => { var result = await handler( FromParameter <T>(method, payload) ); return(ToReturn(result)); }); }
public static async Task <TResult> Call <T, TResult>(this RpcProcessor rpc, string method, T arg1) { var parameters = new[] { ToParameter(arg1) }; var result = await rpc.Invoke(method, parameters); return(FromReturn <TResult>(method, result)); }
public static async Task <TResult> Call <T1, T2, T3, T4, TResult>(this RpcProcessor rpc, string method, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { var parameters = new[] { ToParameter(arg1), ToParameter(arg2), ToParameter(arg3), ToParameter(arg4) }; var result = await rpc.Invoke(method, parameters); return(FromReturn <TResult>(method, result)); }
public static async Task <TResult> Call <TResult>(this RpcProcessor rpc, string method) { var result = await rpc.Invoke(method, new JToken[0]); return(FromReturn <TResult>(method, result)); }
public static void On <T>(this RpcProcessor rpc, string method, Func <T> handler) { rpc.On(method, async() => await Task.Run(handler)); }