public class PacketPreCodec extends Object
| 构造器和说明 |
|---|
PacketPreCodec() |
| 限定符和类型 | 方法和说明 |
|---|---|
byte[] |
getBytes()
Get all bytes of the packet
|
void |
push(byte[] buffer,
int length)
Push the data to the precodec
|
void |
push(byte[] buffer,
int offset,
int length)
Push the data to the precodec
|
byte |
readByte()
Read a byte
|
double |
readDouble()
Read a double
|
float |
readFloat()
Read a float
|
int |
readInt()
Read a integer
|
long |
readLong()
Read a long
|
@Nullable Packet |
readPacket()
Read a packet
|
short |
readShort()
Read a short
|
String |
readString()
Read a string
|
static <T extends Packet> |
registerPacketCodec(int packetId,
PacketCodec<T> packetCodec)
Register the packet codec for the special packet id
|
void |
writeByte(byte b)
Write a byte
|
void |
writeDouble(double v)
Write a double
|
void |
writeFloat(float v)
Write a float
|
void |
writeInt(int v)
Write a integer
|
void |
writeLong(long v)
Write a long
|
<T extends Packet> |
writePacket(T packet)
Write a packet
|
void |
writeShort(short v)
Write a short
|
void |
writeString(String v)
Write a string
|
public int readInt()
public long readLong()
public void writeInt(int v)
v - the integerpublic void writeLong(long v)
v - the longpublic void writeString(String v)
v - the stringpublic String readString()
public void writeFloat(float v)
v - the floatpublic float readFloat()
public void writeDouble(double v)
v - the doublepublic double readDouble()
public byte readByte()
public void writeByte(byte b)
b - the bytepublic short readShort()
public void writeShort(short v)
v - the shortpublic byte[] getBytes()
@Nullable public @Nullable Packet readPacket()
public <T extends Packet> boolean writePacket(T packet)
T - the packet typepacket - the packetpublic static <T extends Packet> void registerPacketCodec(int packetId, PacketCodec<T> packetCodec)
T - the packet typepacketId - the packet idpacketCodec - the packet codecpublic void push(byte[] buffer,
int offset,
int length)
buffer - the dataoffset - the offset of the datalength - the length of the datapush(byte[], int)public void push(byte[] buffer,
int length)
buffer - the datalength - the length of the datapush(byte[], int, int)Copyright © 2022. All rights reserved.