EsotericSoftware / kryonet

TCP/UDP client/server library for Java, based on Kryo
BSD 3-Clause "New" or "Revised" License
1.82k stars 419 forks source link

Added bandwidth monitoring feature #76

Closed cobolfoo closed 9 years ago

cobolfoo commented 10 years ago

There is a change I use in one of my game. It allowed me to track bandwidth usage at bytes level. Both TCP and UDP connection have his own bandwidth monitor.

Typical usage:

To get debug output (current bandwidth once per second in console) client.getTcp().getBandwidth().setDebug(true);

To retrieve last bandwidth information saved: client.getTcp().getBandwidth().getLastInformation();

I could also get all the information saved(several seconds at once): client.getTcp().getBandwidth().getHistory();

By default the history size is set to 120 seconds.

NathanSweet commented 10 years ago

I think it's a useful feature, eg to draw an in-game chart of the network info or maybe to implement UDP flow control, etc. Added some comments above.