当前位置: 首页>>代码示例>>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;未经允许,请勿转载。