Implement the server side - Xenoage/RpcLib GitHub Wiki
- Like on the client side, we also need "stubs" on the server side. See the examples
DemoClientRpcStubandCalcRpcStub. - Implement the server interfaces with the "real" logic. See the example
DemoServerRpc. Within the method calls, you can use the propertyContextto query the calling client's ID and a service factory to use ASP.NET Core dependency injection (see the methodSayHelloToServerfor an example). - Initialize the RPC library on the server side (see example
Startup, the lines after// RPC initialization):- Call the
RpcInit.InitRpcServermethod (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.