I have a program in which I am using an ObjectStream over sockets. Code for the class Im sending looks like the following.
class Snake{
Point[] p = new Point[50];
Direction move;
public int length;
int score;
String player;
Color snakecolor;
boolean gameover;
//Other Functions go here//
}
This Class is sent repeatedly over the socket. However its showing a bit of lag. Would it make that much of a difference if instead of sending the Color object I send an RGB code(integer values)? How could I possibly make my program lag free?
From the documentation, the following fields of Color
are serialized:
int value
float[] frgbvalue
float[] fvalue
float falpha
ColorSpace cs
ColorSpace
has the following serialized fields:
int type
int numComponents
frgbValue
and fvalue
contain 3 elements, so the total size is 40 bytes. Just sending RGB would be 12 bytes. I don't think that's gonna solve your lag.