Answer the question
In order to leave comments, you need to log in
How to calculate the packet size?
I want to send a POJO to the server, for this I create a Message class
public abstract class Message {
// размер пакета
public final int length;
// тип сообщения
public final int typeMessage;
protected Message(int length, int typeMessage) {
this.length = length;
this.typeMessage = typeMessage;
}
public abstract byte[] getBytes();
}
public class Account extends Message {
private char[] email;
private char[] password;
public Account(int length, int typeMessage, char[] email, char[] password) {
super(length, typeMessage);
this.email = email;
this.password = password;
}
public char[] getEmail() {
return email;
}
public void setEmail(char[] email) {
this.email = email;
}
public char[] getPassword() {
return password;
}
public void setPassword(char[] password) {
this.password = password;
}
@Override
public byte[] getBytes() {
return null;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question