Class ClajNet

java.lang.Object
com.xpdustry.claj.common.ClajNet

public class ClajNet extends Object
  • Field Details

    • frameworkId

      public static final byte frameworkId
      Identifier for framework messages.
      See Also:
    • oldId

      public static final byte oldId
      Old CLaJ id.
      See Also:
    • id

      public static final byte id
      Identifier for CLaJ packets.
      See Also:
    • MAX_PACKETS

      public static final int MAX_PACKETS
      Maximum number of packet that can be registered.
      See Also:
  • Constructor Details

    • ClajNet

      public ClajNet()
  • Method Details

    • register

      public static <T extends Packet> void register(arc.func.Prov<T> cons)
      Registers a new packet type for serialization. Ignores if already registered.
      Throws:
      IllegalArgumentException - if no id is available for this packet. (256 packets max)
    • getIndex

      protected static int getIndex(Class<? extends Packet> packet)
    • getIndex

      protected static int getIndex(byte id)
    • getId

      public static byte getId(Packet packet)
    • getId

      public static byte getId(Class<? extends Packet> packet)
    • newPacket

      public static <T extends Packet> T newPacket(byte id)
    • newLocalPacket

      public static <T extends Packet> T newLocalPacket(byte id)
    • newLocalPacket

      public static <T extends Packet> T newLocalPacket(byte id, boolean fast)
      For use with read, if packets are processed on the same thread.
      See Also:
    • newLocalPacket

      public static <T extends Packet> T newLocalPacket(Class<T> packet)
    • newLocalPacket

      public static <T extends Packet> T newLocalPacket(Class<T> packet, boolean fast)
      For use with send, as packets are serialized in-place.

      The fast argument determines whether to use an implementation with a same thread use (MRU) fast path. Default is false.
      You would set it to false only if you think the packet is likely to be frequently used by multiple threads. As the fast path is only faster when a single thread is requesting it intensively.
      The argument is only taken into account during the first call for a given packet.

    • newLocalPacket

      protected static <T extends Packet> T newLocalPacket(int index, boolean fast)
    • newPooledPacket

      public static <T extends Packet> T newPooledPacket(byte id)
      For use with read, as packets are more likely to be processed on another thread.
    • newPooledPacket

      public static <T extends Packet> T newPooledPacket(Class<T> packet)
      For use with send, if packets are serialized on another thread, or for other usages.
    • newPooledPacket

      protected static <T extends Packet> T newPooledPacket(int index)
    • freePooledPacket

      public static <T extends Packet> void freePooledPacket(T packet)
      Never free a packet get from newLocalPacket(byte)!!
    • freePooledPacket

      public static <T extends Packet> void freePooledPacket(byte id, T packet)
      Never free a packet get from newLocalPacket(byte)!!
    • freePooledPacket

      protected static <T extends Packet> void freePooledPacket(int index, T packet)