Search in sources :

Example 1 with Packet

use of io.anuke.mindustry.net.Packet in project Mindustry by Anuken.

the class ByteSerializer method read.

@Override
public Object read(ByteBuffer byteBuffer) {
    try {
        byte id = byteBuffer.get();
        if (id == -2) {
            return FrameworkSerializer.read(byteBuffer);
        } else {
            Class<?> type = Registrator.getByID(id);
            Packet packet = (Packet) ClassReflection.newInstance(type);
            packet.read(byteBuffer);
            return packet;
        }
    } catch (ReflectionException e) {
        throw new RuntimeException(e);
    }
}
Also used : Packet(io.anuke.mindustry.net.Packet) ReflectionException(com.badlogic.gdx.utils.reflect.ReflectionException)

Aggregations

ReflectionException (com.badlogic.gdx.utils.reflect.ReflectionException)1 Packet (io.anuke.mindustry.net.Packet)1