Implement the server side - Xenoage/RpcLib GitHub Wiki
- Like on the client side, we also need "stubs" on the server side. See the examples
DemoClientRpcStub
andCalcRpcStub
. - Implement the server interfaces with the "real" logic. See the example
DemoServerRpc
. Within the method calls, you can use the propertyContext
to query the calling client's ID and a service factory to use ASP.NET Core dependency injection (see the methodSayHelloToServer
for an example). - Initialize the RPC library on the server side (see example
Startup
, the lines after// RPC initialization
):- Call the
RpcInit.InitRpcServer
method (or by extension method style on theservices
) for instantiating the RPC engine, using the ASP.NET Core services, an authentication method (e.g. HTTP Basic Auth) and a list of the types of the implementations of your server-side methods.
- Call the
- To call the clients, create instances of your client stubs and call their methods. To get a list of the currently connected client IDs, call
RpcMain.GetClientIDs()
That's it. Happy coding. Feel free to ask if something is not clear, so we can improve this tutorial.