HTML and CSS Reference
In-Depth Information
Dumb Clients/Authoritative Server
An alternative to having the server dutifully serve whatever the clients report without question is to have an
authoritative server with “dumb” clients. This approach makes cheating less of a problem, while reducing network
traffic. Clients receive routine updates from the server, indicating game state. Player commands are issued as requests
to the server. If it deems a request possible, the server updates its state and sends it to the clients. If a request is
impossible or invalid—for instance, holding down the spacebar to send “rapid-fire” events—the server will drop it.
The server will also combine updates so that it can send out fewer of them.
Its parameters similar to those in Table 11-2 , , Table 11-3 demonstrates how an authoritative server dramatically
reduces load.
Table 11-3. Reducing Load via an Authoritative Server
Number of Clients
Updates Sent to Server
Updates Sent by Server
In the two examples presented here, I talked about the two extremes and chose to view them through the lens
of network load. There are many intermediate variants that take into account the individual needs of the game being
designed. A good place to start is the still relevant Valve paper “Source Multiplayer Networking” ( https://developer. ). Also of interest would be anything on multiplayer
networking from the Association for Computing Machinery Digital Library (ACM DL) or the Institute of Electrical and
Electronics Engineers (IEEE).
Case Studies
So far, you have only looked at WebSockets in the abstract. In the following sections, you will examine source code
from games that use WebSockets.
GRITS is a multiplayer, top-down battle game designed by Google engineers to act as an example implementation
of an HTML5-based game leveraging best-of-breed HTML5 technology, such as Canvas, WebSockets, Google App
Engine, and Google+ integration.
GRITS employs one of the concepts introduced earlier, the authoritative server (see the section “Dumb Clients/
Authoritative Server”). Here, clients send requests for specific actions to the server, the server pushes its state tothe
clients, and the clients see this as the source of truth, overriding any local data. Listing 11-14 displays the setup of
GRITS's socket for handling directional input when using an Android device.
Search WWH ::

Custom Search