Sessions
You have many options for managing game sessions and game state when developing a game. However, it usually comes down to one of two options: session-based games and realm games (also called long-lived sessions).
Session-based games
Session-based games group players together through matchmaking for a single short-lived game session, while realm games run the world simulation continuously, with players joining and leaving the persistent world over time.
In session-based games, players connect to the game server, play during the game session, disconnect, and the game state is reset each time.
The following shows a simple example of a session-based player flow:
- Player connects to the game server
- Player plays game
- Player disconnects from the game server
- Game state cleared for next session
Realm games
In contrast to session-based games, a realm game uses comparatively long-lived sessions, and players expect the game state to have some degree of persistence. Players connect to the game server, play for a while, disconnect, and expect the game data to remain when they reconnect later. In other words, the realm maintains all game state data across all player sessions.
The following shows a simple example of a realm player flow:
- Player connects to the game server
- Player plays game
- Player disconnects from the game server
- Game data persists
- Player reconnects to the game server
Realms often work well for games like massively multiplayer online role-playing games (MMORPG) because the players expect to have the ability to connect and disconnect from the world at their leisure without losing their progress.
There are different degrees of persistence in a realm game: game persistence, world persistence, and data persistence.
- Game persistence refers to the continuation of game events within the world.
- World persistence means the world continues to exist and is available to players when they want to access it. Depending on the game, events might even continue to unfold even when no players interact with the game.
- Data persistence ensures you don’t lose world data during a system failure (like a game server crash).