Hello guys, I’m using KryoNet and I wanted to see how many bytes were (Client-side (sent and received)), could anyone tell me how could I achieve that? I’ve looked everywhere but couldn’t find anything.
My client-side networking looks like this: http://pastebin.java-gaming.org/67c45649299
I’m creating BMONetwork object in my GameScreen class, in it’s update method I check if the users coordinates have changed and if they did I send them to the server. I guess this is where I should check the amount of data that will be sent?
public void update(float delta) {
if (player.getNetworkPosition().x != player.getPosition().x) {
PacketUpdateX packet1 = new PacketUpdateX();
packet1.x = player.getPosition().x;
bmoNetwork.client.sendTCP(packet1);
player.setNetworkPosition(new Vector2(player.getPosition().x, player.getNetworkPosition().y));
}
if (player.getNetworkPosition().y != player.getPosition().y) {
PacketUpdateY packet2 = new PacketUpdateY();
packet2.y = player.getPosition().y;
bmoNetwork.client.sendTCP(packet2);
player.setNetworkPosition(new Vector2(player.getNetworkPosition().x, player.getPosition().y));
}
if (player.getNetworkRotation() != player.getRotation()) {
PacketUpdateRotation packet3 = new PacketUpdateRotation();
packet3.rotation = player.getRotation();
bmoNetwork.client.sendTCP(packet3);
player.setNetworkRotation(player.getRotation());
}
}
If you can help me please provide some code or example how to do it, thanks alot!
[quote]If anyone is interested, to get the sent bytes just do something like this:
bytesSent += bmoNetwork.client.sendTCP(packet);
sendTCP(Object object) method returns the bytes sent, so you can just add them up.
http://i.snag.gy/XghgW.jpg
[/quote]