0

There is not a problem with my code, I would just like to know if sending custom objects in an ArrayList was possible with Kryonet. For example, my game is an MMORPG and there are different maps. When a client requests a map from the server, I would like the return map packet to have an ArrayList of players and entities on the map. is that possible?

Sample Map Packet:

public class MapDataPacket{
    ArrayList<Player> PlayerList = new ArrayList<Player>();
    ArrayList<Entity> EntityList = new ArrayList<Entity>();
    int map_id;
    int[][] tiles;
    //etc...
}

If this is not possible, how would I go about doing this?

vedi0boy
  • 1,030
  • 4
  • 11
  • 32
  • what did you try so far? – chiccodoro Oct 03 '14 at 11:34
  • I didn't try it, I was wondering this before I tried something. – vedi0boy Oct 03 '14 at 11:36
  • So what do you want to do? Serialize `MapDataPacket`? That would be possible if you write `public class MapDataPacket implements Serialziable` and run serialver on your class – msrd0 Oct 03 '14 at 11:40
  • No, I am just wonder if I am able to send a packet with an ArrayList with objects I create that aren't included in Java by default. I know how to send it, I just want to know if it's possible. Beside I may have found a way without ArrayList – vedi0boy Oct 03 '14 at 11:44
  • 1
    I don't know kryonet, but I guess you need to ship the classes so that the Server and the Client have the same classes (or the same serial UID). And don't copy source, copy the generated class file. The JVM can't guess which classes you have, but if the JVM can find them it must work – msrd0 Oct 03 '14 at 11:46
  • Ok thx! I'll use your suggestions. – vedi0boy Oct 03 '14 at 14:12

0 Answers0