In my client application I have two major components:

  1. GameCore - wrapper that handles everything about running the actual game
  2. NetworkClient - A layer that takes care of communicating(receiving/sending packets) with the server.

What I am not sure about is the way the NetworkClient should server information to the GameCore process of the game. The core process has an event queue that is executed in update() calls. My initial idea is to have something like this:

NetworkClient receives a snapshot of the state changes, takes that snapshot and chops it down to event objects for the GameCore process to handle.

The problem I see with that, isn't the NetworkClient class too dependent on the Core class. The oposite is not an issue however because, there can be a different client(udp,tcp etc) that works with the Core class.

So from a design point of view, is there a reason I might not want the NetworkClient class to be written for the specific implementation of the Core class.

PS: I am using JavaScript, but the question does not necessary concern the implementation technology.


1 Answer 1


This is hugely dependent on the type of the game you're creating. For say Chess, the only thing NetworkClient would do is reacting on the move being made and sending that. Some other games might send parts of their state or even the whole state.

In general, you might think about splitting the networking part into two smaller components: the transport that is able to communicate and handles the actual connection, and something like "Network-View" or "Synchronization-View", that's able to take subset of the main game state and send it periodically, react to events and send updates based on those, or both.

That way you separate actual game processing logic from logic used to take the process results and converting them into wire-compatible form. Similarly, on the other side the same part is able to understand the messages and merge them with the present game state.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .