Hello,
I am currently working on a networked game. I was sending positions and that kind of stuff like this:
//out and in are DataOuput and DataInput Streams
out.writeInt(x);
out.writeInt(y);
and receiving it:
in.readInt(x);
in.readInt(y);
I then thought that it was a better practice to send x and y in a single outputstream like this (Thought it will generate less traffic if I send data once and not twice):
out.writeUTF(x@y);
Then I will receive the data like this:
String data[] = in.readUTF.split("@");
x = Integer.parseInt(data[0]);
y = Integer.parseInt(data[1]);
I want to know if this is truly a good approach, is it faster than the one aforementioned. Or is there any other better approach or any suggestion. Thanks,
Elías