I’ve developed a small game i want to make multiplayer.
I’ve made a gameserver, which keeps the client class updated with the current online players and positions.
Now i want to make the Client class feed the Game class with this information, so it’s always up-to-date.
However, creating the Game class with a PlayerList parameter to the constructor will obviously not keep giving the up-to-date informations.
How can i achieve this?
I would actually use a publish-subscribe mechanism where the game server wouldn’t maintain the list of players, but instead publishes the updates to the game domain objects. The players are subscribers or observers who will get notified whenever there is an update from the game server and refreshes the state of domain objects at their side.