Requests and Events

Handling Requests

If calling advance_frame(...) succeeds, GGRS will return a Vec<GGRSRequest>. Handling requests is mandatory. This sequence of requests is order-sensitive! You need to fulfill all requests in order. There are three types of requests: AdvanceFrame, LoadGameState and SaveGameState. Please see 👉BoxGame for a full code example.

AdvanceFrame

AdvanceFrame { inputs: Vec<GameInput> }

Advance the frame with the provided inputs.

LoadGameState

LoadGameState { cell: GameStateCell }

Load a previous gamestate by calling your_state = cell.load(). The provided frame defines from which frame this gamestate is from.

SaveGameState

SaveGameState { cell: GameStateCell, frame: Frame }

Save the current gamestate by calling cell.save(your_state).

Handling Events

Events are notifications from the session for the user. It is recommended to fetch events after every update. Most events are simply of informative nature, requiring no special action from the user. Please see the examples or refer to the documentation what kind of GGRSEvent can occur.

One exception to this is the WaitRecommendation event, which GGRS gives out when your local clients runs too far ahead of remote clients, leading to a lot of one-sided rollbacks on your end. A simple way to mitigate this discrepancy by skipping the indicated amount of frames. More elaborate means to synchronize the clients are described 👉here.