Actually, you just extend them like you do with other classes.
Some things you need to remember:
*Each message needs a "no-args-constructor", an empty constructor with no arguments, for reflection used by JGN.
*Each field needs a getter (possibly a setter as well)
*You need to register each message with JGN (JGN.register(MyMessage.class))
If you forget one of these you might receive various errors, so be careful to remember them.
The message you receive at the other end is the same as the one you sent, you can call the same methods and get the same results.
Although getPlayerId() in Message only returns a player id on the server.
Example:
import com.captiveimagination.jgn.synchronization.message.SynchronizeCreateMessage;
public class MySyncCreateMessage extends SynchronizeCreateMessage{
private int objectId;
private String modelPath;
public MySyncCreateMessage() {
//No-args constructor for reflection
}
public MySyncCreateMessage(int objectId, String modelPath) {
this.objectId = objectId;
this.modelPath = modelPath;
}
public void setObjectId(int num) {
this.objectId = num;
}
public int getObjectId() {
return objectId;
}
public void setModelPath(String str) {
this.modelPath = str;
}
public String getModelPath() {
return modelPath;
}
}
Here you have two extra fields that you can set and get.
Set them on one end, send it over and get it on the other end. As simple as that!
