mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-09-05 10:20:01 +00:00
feat[net]: 增加Jprotobuf的服务器启动支持
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user