Network architectures
Before constructing our architecture, we need some information about what kind of network architectures are commonly used in a game, and their specificities. There are different types of architectures used in game programming. They greatly depend on the game and the needs of the developer. We will see two common architectures: peer-to-peer (P2P) and client-server. Both of them have their strengths and weaknesses. Let's analyze them individually.
Peer-to-peer architecture
This architecture was widely used in the past, and is still used today. In this architecture, players know the addresses of each other and directly communicate with each other without any intermediary. For example, for a game with four different players, the network can be represented as the following chart:
This organization allows a player to directly interact with any or all of the other players. When a client does something, it notifies the others of this action, and they update the simulation (game...