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

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

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

ByteBuf.getUnsignedShort介绍

[英]Gets an unsigned 16-bit short integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
[中]获取此缓冲区中指定绝对索引处的无符号16位短整数。此方法不修改此缓冲区的readerIndex或writerIndex。

代码示例

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

@Override
public int getUnsignedShort(int index) {
  return buf.getUnsignedShort(index);
}

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

@SuppressWarnings("deprecation")
private static int unsignedShortBE(ByteBuf buffer, int offset) {
  return buffer.order() == ByteOrder.BIG_ENDIAN ?
      buffer.getUnsignedShort(offset) : buffer.getUnsignedShortLE(offset);
}

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

@Override
public int getUnsignedShort(int index) {
  return buf.getUnsignedShort(index);
}

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

@SuppressWarnings("deprecation")
private static int unsignedShortBE(ByteBuf buffer, int offset) {
  return buffer.order() == ByteOrder.BIG_ENDIAN ?
      buffer.getUnsignedShort(offset) : buffer.getUnsignedShortLE(offset);
}

代码示例来源:origin: eclipse-vertx/vert.x

public int getUnsignedShort(int pos) {
 return buffer.getUnsignedShort(pos);
}

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

@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
  if (buf.readableBytes() < 20) {
    return null;
  }
  int length;
  if (buf.getUnsignedByte(buf.readerIndex()) == 0x80) {
    length = buf.getUnsignedShortLE(buf.readerIndex() + 6);
  } else {
    length = buf.getUnsignedShort(buf.readerIndex() + 6);
  }
  if (length >= buf.readableBytes()) {
    return buf.readRetainedSlice(length);
  }
  return null;
}

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

@Override
public int getUnsignedShort(final int index) {
 return buffer.getUnsignedShort(index);
}

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

@Override
public int getUnsignedShort(int index) {
  return buf.getUnsignedShort(index);
}

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

@Override
public int getUnsignedShort(int index) {
  return byteBuf.getUnsignedShort(index);
}

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

@Override
public int getUnsignedShort(int index) {
  checkIndex(index, 2);
  return buffer.getUnsignedShort(index);
}

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

@Override
public int getUnsignedShort(int index) {
  checkIndex(index, 2);
  return buffer.getUnsignedShort(index);
}

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

@Override
public int getUnsignedShort(int index) {
  checkIndex(index, 2);
  return buffer.getUnsignedShort(index);
}

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

private static void sendResponse(Channel channel, ByteBuf buf) {
  if (channel != null) {
    ByteBuf response = Unpooled.buffer(4);
    response.writeByte('*');
    response.writeShort(buf.getUnsignedShort(buf.writerIndex() - 2));
    response.writeByte(buf.getUnsignedByte(buf.writerIndex() - 3));
    channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
  }
}

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

@Override
protected Object decode(ChannelHandlerContext ctx, ByteBuf buf) throws Exception {
  if (buf.readableBytes() < MESSAGE_MINIMUM_LENGTH) {
    return null;
  }
  if (buf.getUnsignedShort(buf.readerIndex()) == 0xFAF8) {
    ByteBuf heartbeat = buf.readRetainedSlice(12);
    if (ctx != null && ctx.channel() != null) {
      ctx.channel().writeAndFlush(new NetworkMessage(heartbeat, ctx.channel().remoteAddress()));
    }
  }
  return super.decode(ctx, buf);
}

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

private static double decodeCoordinate(ByteBuf buf) {
  double degrees = buf.getUnsignedShort(buf.readerIndex()) / 100;
  double minutes = buf.readUnsignedShort() % 100 + buf.readUnsignedShort() * 0.0001;
  degrees += minutes / 60;
  byte hemisphere = buf.readByte();
  if (hemisphere == 'S' || hemisphere == 'W') {
    degrees = -degrees;
  }
  return degrees;
}

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

private Object decodeTcp(Channel channel, SocketAddress remoteAddress, ByteBuf buf) throws Exception {
  if (buf.getUnsignedShort(0) > 0) {
    parseIdentification(channel, remoteAddress, buf);
  } else {
    buf.skipBytes(4);
    return parseData(channel, remoteAddress, buf, 0);
  }
  return null;
}

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

@Override
protected Object decode(ChannelHandlerContext ctx, ByteBuf buf) throws Exception {
  // Check minimum length
  if (buf.readableBytes() < MESSAGE_MINIMUM_LENGTH) {
    return null;
  }
  // Check for sync packet
  if (buf.getUnsignedShort(buf.readerIndex()) == 0xFAF8) {
    ByteBuf syncMessage = buf.readRetainedSlice(8);
    if (ctx != null && ctx.channel() != null) {
      ctx.channel().writeAndFlush(new NetworkMessage(syncMessage, ctx.channel().remoteAddress()));
    }
  }
  return super.decode(ctx, buf);
}

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

public static long getUnsignedInteger(final ByteBuf buf, final int offset, final int length) {
  switch (length) {
    case 1:
      return buf.getUnsignedByte(offset);
    case 2:
      return buf.getUnsignedShort(offset);
    case 3:
      return buf.getUnsignedMedium(offset);
    case 4:
      return buf.getUnsignedInt(offset);
    case 8:
      return buf.getLong(offset) & 0x00000000ffffffffL;
    default:
      return 0L;
  }
}

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

break;
case 2:
  frameLength = buf.getUnsignedShort(offset);
  break;
case 3:

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

break;
case 2:
  frameLength = buf.getUnsignedShort(offset);
  break;
case 3:

相关文章

ByteBuf类方法