Unregister RPCs #
There are many reasons why you may want to limit or completely prevent client access to any or all of the Hiro APIs, such as performing validation on a client request or preventing client attempts at circumventing your game logic.
An easy way to do this is to unregister RPCs that you don’t want clients to be able to call directly. You can always make your own custom RPC that implements your own logic before calling the Hiro function from the server-side.
You can find the collection of RPCs that have been registered by Hiro in your Nakama Console -> Runtime Modules -> Registered RPC Functions.
Server Example #
Make sure to first register the Hiro systems that you will be using in your game. Then you can call hiro.UnregisterRpc
, passing in the initializer
followed by as many IDs as you need by using the hiro.RpcId_RPC_ID
consts.
|
|
Custom logic #
In your own RPCs, you can still directly call the Hiro functions after implementing your custom logic. This example shows how we can still directly use ECONOMY_GRANT
on the server-side after unregistering it for clients in the previous example.
|
|
Debug RPCs #
Some Hiro systems have RPCs that are designed for debugging use only, such as in Event Leaderboards.
To unregister all Debug RPCs, call hiro.UnregisterDebugRpc
after you have registered the Hiro systems that you will be using in your game.
|
|