當前位置: 首頁>>代碼示例>>Java>>正文


Java ByteBuf.readUnsignedInt方法代碼示例

本文整理匯總了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;
}
 
開發者ID:MineboxOS,項目名稱:minebox,代碼行數:9,代碼來源:OperationParameters.java

示例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;
    }
 
開發者ID:MineboxOS,項目名稱:minebox,代碼行數:15,代碼來源:HandshakePhase.java

示例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);
}
 
開發者ID:wso2,項目名稱:message-broker,代碼行數:13,代碼來源:LongString.java

示例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);
}
 
開發者ID:wso2,項目名稱:message-broker,代碼行數:16,代碼來源:FieldTable.java

示例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);
}
 
開發者ID:int08h,項目名稱:nearenough,代碼行數:10,代碼來源:RtMessage.java

示例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;
}
 
開發者ID:int08h,項目名稱:nearenough,代碼行數:33,代碼來源:RtMessage.java


注:本文中的io.netty.buffer.ByteBuf.readUnsignedInt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。