本文整理匯總了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;
}