Actually, in most cases the client does not need to "query" the server for anything. Generally in an MMO or online game. Well, it depends on your definition of query I suppose... let us take a look at this in the context of your traditional game.
This answer assumes a stateful simulation, and not a stateless one in which a web-app might utilize (like Google Maps). This is more useful for games.
Let us suppose we have the following diagram:
The box highlighting the character to the left of is the viewport of a client. This would have been determined in one of a few ways:
- The client sent up a value (resolution in a 2D game) in which they can see and the server has interpreted that and stored it
- The game has a fixed viewport for all players, decided ahead of time.
Now, how can we define this viewport? This viewport is known as the area of interest. When something happens in the game world that involves other items are objects, one can query this area of interest viewport to see if it applies. For example, lets consider that "Some Player" wishes to move but our client does not know about them yet.
As long as "Some Player" does not enter the box defined on our client, the client will not know anything about "Some Player" or even that they are moving. However, lets consider this:
Suddenly, the area of interest viewport is now intersecting with "Some Player". This means that updates about and items and information about "Some Player" should now be broadcast. The following should happen when area of interests update:
- If the object does not exist on the client, it should be created.
- All state should be synchronized immediately and updates that are relevant should be subscribed to
Conversely, when an object leaves one can unsubscribe and optional terminate the object in client memory.
This method can apply to a wide variety of games, including top down MMOs, FPS games, and other games where information about a certain "view" needs to be hidden.