Kryonet - how to recognize a packet type?


How does Kryonet recognize different packets? By types, names, bytes?

A friend told me to make a base class named Packet with a String in it, extend it in every single packet class and put a ‘name’ of each packet, but it doesn’t work - Kryonet is faster and shows in the console, that the wrong packet has been read.

I just don’t know how to discover similar packet types (with only different names).

Here is an example:

  static public class PlayerPosition extends Packet{
        public float x, y;

    static public class StartingLeft extends Packet{
        public boolean startingLeft;

    static public class ReadyForCasualGame extends Packet{


    static public class IamReady extends Packet{


When I send ‘ReadyForCasualGame’ from the client, the server always reads this as ‘IamReady’ packet.