Book Image

JMonkeyEngine 3.0 Cookbook

By : Rickard Eden
Book Image

JMonkeyEngine 3.0 Cookbook

By: Rickard Eden

Overview of this book

Table of Contents (17 chapters)
jMonkeyEngine 3.0 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Optimizing the bandwidth and avoiding cheating


It can be summarized as follows: the less information a client has, the less opportunity there is of exploiting said information for cheating. Also, the less information a client needs, the less bandwidth is required.

Previously, we've generously sent information about every player, every update cycle. In this recipe, we'll change that so that the server checks what players can be seen by others, and only send that information.

We'll build this on top of the Implementing a network code for FPS recipe.

We need to add some complexity to the simpleUpdate method of the server application. So, instead of sending information about all players to everybody, we need to check who should receive what.

How to do it...

Perform the following steps to optimize a bandwidth:

  1. First of all, we'll add a visible field to our PlayerUpdateMessage. This is so that a client knows when a player has disappeared from the view.

  2. On the server side, we need to change two classes...