Class ClajNet
java.lang.Object
com.xpdustry.claj.common.ClajNet
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byteIdentifier for framework messages.static final byteIdentifier for CLaJ packets.static final intMaximum number of packet that can be registered.static final byteOld CLaJ id. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Packet>
voidfreePooledPacket(byte id, T packet) Never free a packet get fromnewLocalPacket(byte)!!protected static <T extends Packet>
voidfreePooledPacket(int index, T packet) static <T extends Packet>
voidfreePooledPacket(T packet) Never free a packet get fromnewLocalPacket(byte)!!static bytestatic byteprotected static intgetIndex(byte id) protected static intstatic <T extends Packet>
TnewLocalPacket(byte id) static <T extends Packet>
TnewLocalPacket(byte id, boolean fast) For use with read, if packets are processed on the same thread.protected static <T extends Packet>
TnewLocalPacket(int index, boolean fast) static <T extends Packet>
TnewLocalPacket(Class<T> packet) static <T extends Packet>
TnewLocalPacket(Class<T> packet, boolean fast) For use with send, as packets are serialized in-place.static <T extends Packet>
TnewPacket(byte id) static <T extends Packet>
TnewPooledPacket(byte id) For use with read, as packets are more likely to be processed on another thread.protected static <T extends Packet>
TnewPooledPacket(int index) static <T extends Packet>
TnewPooledPacket(Class<T> packet) For use with send, if packets are serialized on another thread, or for other usages.static <T extends Packet>
voidregister(arc.func.Prov<T> cons) Registers a new packet type for serialization.
-
Field Details
-
frameworkId
public static final byte frameworkIdIdentifier for framework messages.- See Also:
-
oldId
public static final byte oldIdOld CLaJ id.- See Also:
-
id
public static final byte idIdentifier for CLaJ packets.- See Also:
-
MAX_PACKETS
public static final int MAX_PACKETSMaximum number of packet that can be registered.- See Also:
-
-
Constructor Details
-
ClajNet
public ClajNet()
-
-
Method Details
-
register
Registers a new packet type for serialization. Ignores if already registered.- Throws:
IllegalArgumentException- if no id is available for this packet. (256packets max)
-
getIndex
-
getIndex
protected static int getIndex(byte id) -
getId
-
getId
-
newPacket
-
newLocalPacket
-
newLocalPacket
For use with read, if packets are processed on the same thread.- See Also:
-
newLocalPacket
-
newLocalPacket
For use with send, as packets are serialized in-place.The
fastargument determines whether to use an implementation with a same thread use (MRU) fast path. Default isfalse.
You would set it tofalseonly 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
-
newPooledPacket
For use with read, as packets are more likely to be processed on another thread. -
newPooledPacket
-
newPooledPacket
-
freePooledPacket
Never free a packet get fromnewLocalPacket(byte)!! -
freePooledPacket
Never free a packet get fromnewLocalPacket(byte)!! -
freePooledPacket
-