feat[net]: 增加Jprotobuf的服务器启动支持

This commit is contained in:
jaysunxiao
2022-01-12 11:28:38 +08:00
parent 1853254f00
commit 0f8870a794
12 changed files with 502 additions and 1 deletions
@@ -46,6 +46,10 @@ public abstract class ByteBufUtils {
return byteBuf.readBoolean();
}
public static boolean tryReadBoolean(ByteBuf byteBuf) {
return byteBuf.isReadable() && readBoolean(byteBuf);
}
public static void writeBooleanBox(ByteBuf byteBuf, Boolean value) {
byteBuf.writeBoolean(value != null && value);
}
@@ -71,6 +75,13 @@ public abstract class ByteBufUtils {
return byteBuf.readByte();
}
public static byte[] readAllBytes(ByteBuf byteBuf) {
var readableBytes = byteBuf.readableBytes();
var bytes = new byte[readableBytes];
byteBuf.readBytes(bytes);
return bytes;
}
//---------------------------------short--------------------------------------
public static void writeShort(ByteBuf byteBuf, short value) {
byteBuf.writeShort(value);