io.netty.buffer.ByteBuf.readUnsignedInt()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(162)

本文整理了Java中io.netty.buffer.ByteBuf.readUnsignedInt()方法的一些代码示例,展示了ByteBuf.readUnsignedInt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuf.readUnsignedInt()方法的具体详情如下:
包路径:io.netty.buffer.ByteBuf
类名称:ByteBuf
方法名:readUnsignedInt

ByteBuf.readUnsignedInt介绍

[英]Gets an unsigned 32-bit integer at the current readerIndexand increases the readerIndex by 4 in this buffer.
[中]获取当前readerIndex处的无符号32位整数,并在此缓冲区中将readerIndex增加4。

代码示例

代码示例来源:origin: netty/netty

@Override
public long readUnsignedInt() {
  return buf.readUnsignedInt();
}

代码示例来源:origin: redisson/redisson

@Override
public long readUnsignedInt() {
  return buf.readUnsignedInt();
}

代码示例来源:origin: wildfly/wildfly

@Override
public long readUnsignedInt() {
 return buffer.readUnsignedInt();
}

代码示例来源:origin: wildfly/wildfly

@Override
public long readUnsignedInt() {
  return buf.readUnsignedInt();
}

代码示例来源:origin: traccar/traccar

private double readCoordinate(ByteBuf buf, boolean extended) {
  long value = buf.readUnsignedInt();
  if (extended ? (value & 0x08000000) != 0 : (value & 0x00800000) != 0) {
    value |= extended ? 0xF0000000 : 0xFF000000;
  }
  return (int) value / (extended ? 360000.0 : 3600.0);
}

代码示例来源:origin: micronaut-projects/micronaut-core

@Override
public long readUnsignedInt() {
  return byteBuf.readUnsignedInt();
}

代码示例来源:origin: Graylog2/graylog2-server

/**
 * @see <a href="https://github.com/logstash-plugins/logstash-input-beats/blob/master/PROTOCOL.md#window-size-frame-type">'window size' frame type</a>
 */
private void processWindowSizeFrame(ByteBuf channelBuffer) {
  windowSize = channelBuffer.readUnsignedInt();
  LOG.trace("Changed window size to {}", windowSize);
}

代码示例来源:origin: netty/netty

@Override
public long readUnsignedInt() {
  checkReadableBytes(4);
  return buffer.readUnsignedInt();
}

代码示例来源:origin: redisson/redisson

@Override
public long readUnsignedInt() {
  checkReadableBytes(4);
  return buffer.readUnsignedInt();
}

代码示例来源:origin: Graylog2/graylog2-server

/**
 * <a href="https://github.com/logstash-plugins/logstash-input-beats/blob/master/PROTOCOL.md#json-frame-type">'json' frame type</a>
 */
private Collection<ByteBuf> parseJsonFrame(Channel channel, ByteBuf channelBuffer) throws IOException {
  sequenceNum = channelBuffer.readUnsignedInt();
  LOG.trace("Received sequence number {}", sequenceNum);
  final int jsonLength = Ints.saturatedCast(channelBuffer.readUnsignedInt());
  final ByteBuf buffer = channelBuffer.readBytes(jsonLength);
  sendACK(channel);
  return Collections.singleton(buffer);
}

代码示例来源:origin: Graylog2/graylog2-server

/**
 * @see <a href="https://github.com/logstash-plugins/logstash-input-beats/blob/master/PROTOCOL.md#compressed-frame-type">'compressed' frame type</a>
 */
private Collection<ByteBuf> processCompressedFrame(Channel channel, ByteBuf channelBuffer) throws Exception {
  final long payloadLength = channelBuffer.readUnsignedInt();
  final byte[] data = new byte[(int) payloadLength];
  channelBuffer.readBytes(data);
  try (final ByteArrayInputStream dataStream = new ByteArrayInputStream(data);
     final InputStream in = new InflaterInputStream(dataStream)) {
    final ByteBuf buffer = Unpooled.wrappedBuffer(ByteStreams.toByteArray(in));
    return processCompressedDataFrames(channel, buffer);
  }
}

代码示例来源:origin: wildfly/wildfly

private void readRstStreamFrame(ChannelHandlerContext ctx, ByteBuf payload,
    Http2FrameListener listener) throws Http2Exception {
  long errorCode = payload.readUnsignedInt();
  listener.onRstStreamRead(ctx, streamId, errorCode);
}

代码示例来源:origin: wildfly/wildfly

@Override
public long readUnsignedInt() {
  checkReadableBytes(4);
  return buffer.readUnsignedInt();
}

代码示例来源:origin: Graylog2/graylog2-server

private String parseDataItem(ByteBuf buf) {
  int length = Ints.saturatedCast(buf.readUnsignedInt());
  final ByteBuf item = buf.readSlice(length);
  return item.toString(StandardCharsets.UTF_8);
}

代码示例来源:origin: Graylog2/graylog2-server

private Optional<Object> parseUnsignedNumber(ByteBuf bb, int length) {
    switch (length) {
      case 1:
        return Optional.of(bb.readUnsignedByte());
      case 2:
        return Optional.of(bb.readUnsignedShort());
      case 3:
        return Optional.of(bb.readUnsignedMedium());
      case 4:
        return Optional.of(bb.readUnsignedInt());
      case 8:
        return Optional.of(bb.readLong());
      default:
        byte[] uint64Bytes = new byte[length];
        bb.readBytes(uint64Bytes);
        return Optional.of(new BigInteger(uint64Bytes));
    }

  }
}

代码示例来源:origin: traccar/traccar

private long readValue(ByteBuf buf, int length, boolean signed) {
  switch (length) {
    case 1:
      return signed ? buf.readByte() : buf.readUnsignedByte();
    case 2:
      return signed ? buf.readShort() : buf.readUnsignedShort();
    case 4:
      return signed ? buf.readInt() : buf.readUnsignedInt();
    default:
      return buf.readLong();
  }
}

代码示例来源:origin: traccar/traccar

private long readValue(ByteBuf buf, int length, boolean signed) {
  switch (length) {
    case 1:
      return signed ? buf.readByte() : buf.readUnsignedByte();
    case 2:
      return signed ? buf.readShort() : buf.readUnsignedShort();
    case 4:
      return signed ? buf.readInt() : buf.readUnsignedInt();
    default:
      return buf.readLong();
  }
}

代码示例来源:origin: wildfly/wildfly

private static void readGoAwayFrame(ChannelHandlerContext ctx, ByteBuf payload,
    Http2FrameListener listener) throws Http2Exception {
  int lastStreamId = readUnsignedInt(payload);
  long errorCode = payload.readUnsignedInt();
  ByteBuf debugData = payload.readSlice(payload.readableBytes());
  listener.onGoAwayRead(ctx, lastStreamId, errorCode, debugData);
}

代码示例来源:origin: redisson/redisson

@Override
public final <T extends DnsRecord> T decodeRecord(ByteBuf in) throws Exception {
  final int startOffset = in.readerIndex();
  final String name = decodeName(in);
  final int endOffset = in.writerIndex();
  if (endOffset - startOffset < 10) {
    // Not enough data
    in.readerIndex(startOffset);
    return null;
  }
  final DnsRecordType type = DnsRecordType.valueOf(in.readUnsignedShort());
  final int aClass = in.readUnsignedShort();
  final long ttl = in.readUnsignedInt();
  final int length = in.readUnsignedShort();
  final int offset = in.readerIndex();
  if (endOffset - offset < length) {
    // Not enough data
    in.readerIndex(startOffset);
    return null;
  }
  @SuppressWarnings("unchecked")
  T record = (T) decodeRecord(name, type, aClass, ttl, in, offset, length);
  in.readerIndex(offset + length);
  return record;
}

代码示例来源:origin: wildfly/wildfly

private void readPriorityFrame(ChannelHandlerContext ctx, ByteBuf payload,
    Http2FrameListener listener) throws Http2Exception {
  long word1 = payload.readUnsignedInt();
  boolean exclusive = (word1 & 0x80000000L) != 0;
  int streamDependency = (int) (word1 & 0x7FFFFFFFL);
  if (streamDependency == streamId) {
    throw streamError(streamId, PROTOCOL_ERROR, "A stream cannot depend on itself.");
  }
  short weight = (short) (payload.readUnsignedByte() + 1);
  listener.onPriorityRead(ctx, streamId, streamDependency, weight, exclusive);
}

相关文章

ByteBuf类方法