本文整理汇总了Java中io.netty.buffer.ByteBuf.readUnsignedInt方法的典型用法代码示例。如果您正苦于以下问题:Java ByteBuf.readUnsignedInt方法的具体用法?Java ByteBuf.readUnsignedInt怎么用?Java ByteBuf.readUnsignedInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.buffer.ByteBuf
的用法示例。
在下文中一共展示了ByteBuf.readUnsignedInt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: OperationParameters
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
private OperationParameters(ByteBuf message) {
cmdFlags = message.readShort();
cmdType = message.readShort();
cmdHandle = message.readLong();
cmdOffset = message.readLong();
cmdLength = message.readUnsignedInt();
state = State.TM_RECEIVE_CMD_DATA;
}
示例2: receiveHandshakeOption
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
private void receiveHandshakeOption(ChannelHandlerContext ctx, ByteBuf message) throws IOException {
final long ihaveopt = message.readLong();
if (ihaveopt != Protocol.IHAVEOPT)
throw new IllegalArgumentException("Invalid negotiation magic != 'IHAVEOPT'");
int option = message.readInt();
long optionLen = message.readUnsignedInt();
currentOption = option;
currentOptionLen = optionLen;
LOGGER.debug("currentOption {} currentOptionLen {}", currentOption, currentOptionLen);
state = State.HS_OPTION_DATA;
}
示例3: parse
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
public static LongString parse(ByteBuf buf) throws Exception {
int size = (int) buf.readUnsignedInt();
if (size < 0) {
throw new Exception("Invalid string length");
}
byte[] data = new byte[size];
buf.readBytes(data);
return new LongString(size, data);
}
示例4: parse
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
public static FieldTable parse(ByteBuf buf) throws Exception {
long size = buf.readUnsignedInt();
long readBytes = 0L;
Map<ShortString, FieldValue> properties = new HashMap<>();
while (readBytes < size) {
ShortString key = ShortString.parse(buf);
FieldValue value = FieldValue.parse(buf);
properties.put(key, value);
readBytes = readBytes + key.getSize() + value.getSize();
}
return new FieldTable(properties);
}
示例5: extractSingleMapping
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
private Map<RtTag, byte[]> extractSingleMapping(ByteBuf msg) {
long uintTag = msg.readUnsignedInt();
RtTag tag = RtTag.fromUnsignedInt((int) uintTag);
byte[] value = new byte[msg.readableBytes()];
msg.readBytes(value);
return Collections.singletonMap(tag, value);
}
示例6: extractMultiMapping
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
private Map<RtTag, byte[]> extractMultiMapping(ByteBuf msg) {
// extractOffsets will leave the reader index positioned at the first tag
int[] offsets = extractOffsets(msg);
int startOfValues = msg.readerIndex() + (4 * numTags);
Map<RtTag, byte[]> mapping = new LinkedHashMap<>(numTags);
RtTag prevTag = null;
for (int i = 0; i < offsets.length; i++) {
long uintCurrTag = msg.readUnsignedInt();
RtTag currTag = RtTag.fromUnsignedInt((int) uintCurrTag);
if ((prevTag != null) && currTag.isLessThan(prevTag)) {
String exMsg = String.format(
"tags not strictly increasing: current '%s' (0x%08x), previous '%s' (0x%08x)",
currTag, currTag.valueLE(), prevTag, prevTag.valueLE()
);
throw new TagsNotIncreasingException(exMsg);
}
int valueIdx = startOfValues + offsets[i];
int valueLen = ((i + 1) == offsets.length) ? msg.readableBytes() - offsets[i]
: offsets[i + 1] - offsets[i];
byte[] valueBytes = new byte[valueLen];
msg.getBytes(valueIdx, valueBytes);
mapping.put(currTag, valueBytes);
prevTag = currTag;
}
return mapping;
}