Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [KryoNet] How to get the amount of bytes received/sent?  (Read 3631 times)
0 Members and 1 Guest are viewing this topic.
Offline Edgu

Senior Newbie





« Posted 2014-06-25 18:22:54 »

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.  Sad

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?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
   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!  Tongue

Quote
If anyone is interested, to get the sent bytes just do something like this:

1  
bytesSent += bmoNetwork.client.sendTCP(packet);


sendTCP(Object object) method returns the bytes sent, so you can just add them up.

Offline ctomni231

JGO Wizard


Medals: 99
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #1 - Posted 2014-06-28 04:32:21 »

But but but... they have full examples in the website, and you can find the answer with just a little bit of digging around. Here, I'll give you two very relevant web pages you can scour to get the answer to this...

https://github.com/EsotericSoftware/kryonet#buffer-sizes
https://code.google.com/p/kryonet/source/browse/trunk/kryonet/examples/com/esotericsoftware/kryonet/examples/position/PositionClient.java

Offline Edgu

Senior Newbie





« Reply #2 - Posted 2014-06-29 14:07:55 »

But but but... they have full examples in the website, and you can find the answer with just a little bit of digging around. Here, I'll give you two very relevant web pages you can scour to get the answer to this...

https://github.com/EsotericSoftware/kryonet#buffer-sizes
https://code.google.com/p/kryonet/source/browse/trunk/kryonet/examples/com/esotericsoftware/kryonet/examples/position/PositionClient.java

Thanks, I've found a way how to get sent bytes, but I still can't figure out how to get received bytes. Clueless
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Longarmx
« Reply #3 - Posted 2014-06-29 17:32:21 »

Please do not delete and then repost the exact same message in an effort to bump your thread.  Smiley

Offline Edgu

Senior Newbie





« Reply #4 - Posted 2014-06-29 20:08:23 »

Please do not delete and then repost the exact same message in an effort to bump your thread.  Smiley
Is it against the rules?
Online BurntPizza

« JGO Bitwise Duke »


Medals: 289
Exp: 5 years



« Reply #5 - Posted 2014-06-29 20:09:53 »

Not really (AFAIK), but it's mostly pointless (people will see it even without bump) and somewhat annoying, and thus frowned upon I'd say.
Offline Edgu

Senior Newbie





« Reply #6 - Posted 2014-06-29 20:16:12 »

Not really (AFAIK), but it's mostly pointless (people will see it even without bump) and somewhat annoying, and thus frowned upon I'd say.

Umm okay, wont happen again. Now can someone help me please?  Huh
Offline ctomni231

JGO Wizard


Medals: 99
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #7 - Posted 2014-06-29 20:16:28 »

 How you receive bytes is completely dependent on how you set your server up in the first place. If you don't have a server that accepts Java code, then you won't be able to use server side Kyronet. The information given here is so little. What have you tried so far in terms of getting this to work? What kind of server service are you using?

Offline Edgu

Senior Newbie





« Reply #8 - Posted 2014-06-29 20:27:11 »

How you receive bytes is completely dependent on how you set your server up in the first place. If you don't have a server that accepts Java code, then you won't be able to use server side Kyronet. The information given here is so little. What have you tried so far in terms of getting this to work? What kind of server service are you using?

I do have working server which is written in java + using KryoNet.
Server looks like this: http://pastebin.com/0LWrTyGN

But I think you misunderstood my problem, I want to get the amount of bytes the client has received from the server. I think so that this has to be done in BMONetwork received() method but I have no idea how to do that because at that method what is received is a whole object deserialized from the bytes. Everything works fine I just want to keep track of amount of bytes that were received, that's it.
Offline Edgu

Senior Newbie





« Reply #9 - Posted 2014-07-10 19:23:38 »

Sorry for bumping again, but could anyone help me please?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ctomni231

JGO Wizard


Medals: 99
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #10 - Posted 2014-07-12 06:18:31 »

Kyronet is built on top of Java NIO, if you want to figure out how to get packet data down to the bytes, I'd start there. Use the source code to help you track your solution, because your solution lies in Java NIO.

https://code.google.com/p/kryonet/source/browse/trunk/kryonet/src/com/esotericsoftware/kryonet/Client.java?r=122#5

But, the Github page is probably a much better search point... Best of luck. Also, best try not to do too many bumps, as there are hungry monsters running around these parts.  Pointing

Offline seismic

Senior Devvie


Medals: 4
Projects: 1



« Reply #11 - Posted 2014-07-12 07:46:54 »

I do think this should be a little easier to do with Kryo tho. Why is it such a chore to do something "that easy" with Kryo, whereas with other Libraries it's just a matter of saving the return value?
Pages: [1]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (35 views)
2014-12-15 09:26:44

Mr.CodeIt (26 views)
2014-12-14 19:50:38

BurntPizza (60 views)
2014-12-09 22:41:13

BurntPizza (95 views)
2014-12-08 04:46:31

JscottyBieshaar (55 views)
2014-12-05 12:39:02

SHC (71 views)
2014-12-03 16:27:13

CopyableCougar4 (73 views)
2014-11-29 21:32:03

toopeicgaming1999 (133 views)
2014-11-26 15:22:04

toopeicgaming1999 (124 views)
2014-11-26 15:20:36

toopeicgaming1999 (34 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!