Awaitable RPC
Last updated
Last updated
Awaitable RPCs is a gamechanger for networking and optimal development properly integrating with the natural workflow of C#
They utilize Tasks and also support UniTask. optionally they can be made async as well.
It not only allows for you to wait till RPC logic is finished, but allows you to return values from the receiving end of the RPC.
Below is a real use-case example of a way for the player to set ready on the server and it will return true if all players are ready, and false if not all players are ready (handled by the CheckForReady method)
It also has a fail safe in with the networked State Machine setup in case this isn't the game state were in:
And for the client all that needs to be done is have an async method which can await for the result of the RPC. You can read more about the async keyword here. Essentially it will allow the method to run asynchronous of your otherwise fully sequential code, allowing it to halt execution until it has received a response.
Here is the bare minimum of using this setup