本文整理汇总了Java中io.netty.buffer.ByteBuf.readMedium方法的典型用法代码示例。如果您正苦于以下问题:Java ByteBuf.readMedium方法的具体用法?Java ByteBuf.readMedium怎么用?Java ByteBuf.readMedium使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.buffer.ByteBuf
的用法示例。
在下文中一共展示了ByteBuf.readMedium方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decode
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
if (!hasHeader) {
if (in.readableBytes() >= 7) {
short id = in.readShort();
int payloadLength = in.readMedium();
short version = in.readShort();
hasHeader = true;
header.id = id;
header.payload = new byte[payloadLength];
}
} else {
if (in.readableBytes() >= header.payload.length) {
in.readBytes(header.payload);
hasHeader = false;
crypto.decryptPacket(header);
ClientMessage message = processPacket();
if (message != null) {
out.add(message);
}
}
}
}
示例2: decode
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
/**
* Decodes the machine information of the user during the {@link WorldLoginDecoder}.
*
* @param buffer The {@link ByteBuf}.
* @return The created machine information.
*/
public static MachineInformation decode(ByteBuf buffer) {
buffer.readByte();
int osArch = buffer.readByte();
boolean is64Bit = buffer.readByte() == 1;
int osBuild = buffer.readByte();
int vendor = buffer.readByte();
buffer.readByte();
buffer.readByte();
buffer.readByte();
buffer.readByte();
buffer.readShort();
buffer.readByte();
buffer.readMedium();
buffer.readShort();
ByteBufUtils.readJagString(buffer);
ByteBufUtils.readJagString(buffer);
ByteBufUtils.readJagString(buffer);
ByteBufUtils.readJagString(buffer);
buffer.readByte();
buffer.readShort();
ByteBufUtils.readJagString(buffer);
ByteBufUtils.readJagString(buffer);
buffer.readByte();
buffer.readByte();
return new MachineInformation(osArch, is64Bit, osBuild, vendor);
}