public interface PacketCoder<T>
static PacketCoder<String>
STRING_CODER
T
decode(byte[] bytes)
byte[]
encode(T t)
static final PacketCoder<String> STRING_CODER
byte[] encode(T t)
t
T decode(byte[] bytes)
提示:之所以用bytes 入参,是为了减少对 netty 的依赖,使开发者直接使用熟悉的字节操作。
读取之后,如果解码成功,需要设置读取的字节数,用来设置内置缓冲区。
如果没有解码成功,可以返回 null 或者 DecodePacket.NULL
bytes
Copyright © 2022. All rights reserved.