NetFourByFour is based on the
FourByFour game, retaining most of its game logic, 3D modeling, and GUI interface, and it adds a threaded client/server communications layer.
This development sequence is deliberate, as it allows most of the game-specific and user interface issues to be addressed before networking complexity is introduced.
Figure 31-6 shows the main functional components of
Figure 31-6. NetFourByFour clients and server
The top-level server,
FBFServer, creates two
PlayServerHandler threads to manage communication between the players. The server and its threads are thin in that they carry out little processing and act mainly as a switchboard for messages passing between the players.
An advantage of this approach is that most of the client's functionality can be borrowed from the standalone
FourByFour, and the server side is kept simple. Processing is carried out locally in the client, whereas server-side processing would introduce networking delays between the user's selection and the resulting changes in the game window. A drawback is the need to duplicate processing across the clients.
NetFourByFour client utilizes the Java 3D GUI thread (where
PickDragBehavior executes), the application thread for game processing, and an
FBFWatcher thread to handle messages coming from the server. This threaded model was last seen in the ...