[英]Size of java.awt.Color object
I have a program in which I am using an ObjectStream over sockets. 我有一个在套接字上使用ObjectStream的程序。 Code for the class Im sending looks like the following.
Im发送的类的代码如下所示。
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)?
如果不是发送Color对象而是发送RGB代码(整数值),是否会有很大的不同? How could I possibly make my program lag free?
我怎样才能使程序没有延迟?
From the documentation , the following fields of Color
are serialized: 从文档中 ,将对
Color
的以下字段进行序列化:
int value
float[] frgbvalue
float[] fvalue
float falpha
ColorSpace cs
ColorSpace
has the following serialized fields : ColorSpace
具有以下序列化字段 :
int type
int numComponents
frgbValue
and fvalue
contain 3 elements, so the total size is 40 bytes. frgbValue
和fvalue
包含3个元素,因此总大小为40个字节。 Just sending RGB would be 12 bytes. 仅发送RGB就是12个字节。 I don't think that's gonna solve your lag.
我认为那不会解决您的延迟。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.