Package crow.game.codec
Interface PacketReader
- All Known Implementing Classes:
ByteBufPacketReader
public interface PacketReader
Interface for decoding packets into data.
used to abstract out the implementation details of netty.
-
Method Summary
Modifier and TypeMethodDescription<T> TbytereadByte()byte[]readBytes(int length) Reads the address and port pair from the kro server byte stream, which is a 6-byte series.intlongshortreadString(int length) Reads the next N bytes as a string.intsize()voidskip(int length) Skip N bytes
-
Method Details
-
readString
Reads the next N bytes as a string.NOTE:Strings in KRO are 0-terminated and use pre-determined lengths. So "hello" of length 20 will be "hello" 0x0 0x0 0x0...
- Parameters:
length- the size of the string, with zero padding.- Returns:
- The string object.
-
readBytes
byte[] readBytes(int length) -
readInetAddressAndPort
Reads the address and port pair from the kro server byte stream, which is a 6-byte series.- Returns:
- The IP address and port pair
- Throws:
UnknownHostException- See Also:
-
skip
void skip(int length) Skip N bytes- Parameters:
length- number of bytes to skip
-
readShortLE
short readShortLE()- Returns:
- the next 4-byte short in the stream
-
readIntLE
int readIntLE()- Returns:
- the next 4-byte integer in the stream
-
readByte
byte readByte()- Returns:
- the next byte in the stream
-
getUnderlyingObject
<T> T getUnderlyingObject()- Type Parameters:
T- The underlying object type.- Returns:
- The underlying object that backs this packet reader, usually a byte buffer.
-
size
int size()- Returns:
- the size of the packet
-
readLongLE
long readLongLE()
-