Define RPC methods - Xenoage/RpcLib GitHub Wiki
In the shared class library project (or in any source folder both the server and the client can access) define the interfaces containing the methods which are available on the server (see example IDemoServerRpc
) and on the client (see example IDemoClientRpc
). It is also possible to distribute the functions over several interfaces/classes and use the implementations both server-side and client-side, as demonstrated with the example ICalcRpc
.
- All methods must return a
Task
or aTask<T>
, because they are called asynchronously. - Both the return type (if any) and the parameters (if any) must be (de)serializable to/from JSON. Internally, we use the Newtonsoft.JSON library for (de)serialization.
There are more options to configure the calling of the methods, e.g. setting the timeout, automatic retry or compression.
Proceed with implementing the client side.