Introduction
The Game Server (known as Hagrid) is responsible for a number of critical tasks:
- Connecting players to the central game server after authentication.
- Matchmaking players into and managing the state of multiplayer game rooms.
- Handling requests from game clients.
- Making requests to the API, and if necessary, returning responses to players.
An active connection to the Game Server from the Client is required for the game to function. If a Player is unexpectedly disconnected from the Game Server, the Client will attempt to reconnect. In the event a connection cannot quickly be reestablished, the Player is returned to the main menu. This is crucial to protect the integrity of game state and prevent abuse.
Architecture
Idlerun uses Colyseus for its Game Server architecture. Colyseus provides out-of-the-box functionality for managing connections, matchmaking into rooms, game state, presence, and scaling.
The Game Server is considered to be a broker; a Game Server instance is only used for receiving requests and keeping game state in sync across Client instances. For every request to a Game Server that results in business logic, game logic, or mutations of data: a subsequent request is made to the API which will be handled asynchronously.