Record Class PacketHeader
java.lang.Object
java.lang.Record
com.quietterminal.neon.core.PacketHeader
public record PacketHeader(short magic, byte version, byte packetType, short sequence, byte clientId, byte destinationId)
extends Record
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final shortstatic final byte -
Constructor Summary
ConstructorsConstructorDescriptionPacketHeader(short magic, byte version, byte packetType, short sequence, byte clientId, byte destinationId) Creates an instance of aPacketHeaderrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbyteclientId()Returns the value of theclientIdrecord component.static PacketHeadercreate(byte packetType, short sequence, byte clientId, byte destinationId) byteReturns the value of thedestinationIdrecord component.final booleanIndicates whether some other object is "equal to" this one.static PacketHeaderfromBytes(byte[] data) final inthashCode()Returns a hash code value for this object.shortmagic()Returns the value of themagicrecord component.byteReturns the value of thepacketTyperecord component.shortsequence()Returns the value of thesequencerecord component.byte[]toBytes()final StringtoString()Returns a string representation of this record class.byteversion()Returns the value of theversionrecord component.
-
Field Details
-
MAGIC
public static final short MAGIC- See Also:
-
VERSION
public static final byte VERSION- See Also:
-
HEADER_SIZE
public static final int HEADER_SIZE- See Also:
-
-
Constructor Details
-
PacketHeader
public PacketHeader(short magic, byte version, byte packetType, short sequence, byte clientId, byte destinationId) Creates an instance of aPacketHeaderrecord class.- Parameters:
magic- the value for themagicrecord componentversion- the value for theversionrecord componentpacketType- the value for thepacketTyperecord componentsequence- the value for thesequencerecord componentclientId- the value for theclientIdrecord componentdestinationId- the value for thedestinationIdrecord component
-
-
Method Details
-
create
public static PacketHeader create(byte packetType, short sequence, byte clientId, byte destinationId) -
toBytes
public byte[] toBytes() -
fromBytes
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with thecomparemethod from their corresponding wrapper classes. -
magic
public short magic()Returns the value of themagicrecord component.- Returns:
- the value of the
magicrecord component
-
version
public byte version()Returns the value of theversionrecord component.- Returns:
- the value of the
versionrecord component
-
packetType
public byte packetType()Returns the value of thepacketTyperecord component.- Returns:
- the value of the
packetTyperecord component
-
sequence
public short sequence()Returns the value of thesequencerecord component.- Returns:
- the value of the
sequencerecord component
-
clientId
public byte clientId()Returns the value of theclientIdrecord component.- Returns:
- the value of the
clientIdrecord component
-
destinationId
public byte destinationId()Returns the value of thedestinationIdrecord component.- Returns:
- the value of the
destinationIdrecord component
-