Codota Logo
ByteBuf.readByte
Code IndexAdd Codota to your IDE (free)

How to use
readByte
method
in
io.netty.buffer.ByteBuf

Best Java code snippets using io.netty.buffer.ByteBuf.readByte (Showing top 20 results out of 6,318)

Refine searchRefine arrow

  • ByteBuf.readerIndex
  • ByteBuf.readableBytes
  • Logger.isTraceEnabled
  • Logger.trace
  • ByteBuf.readShort
  • ByteBuf.readInt
  • Common ways to obtain ByteBuf
private void myMethod () {
ByteBuf b =
  • Codota IconUnpooled.buffer()
  • Codota IconChannelHandlerContext ctx;ctx.alloc().buffer()
  • Smart code suggestions by Codota
}
origin: mpusher/mpush

public static Packet decodePacket(Packet packet, ByteBuf in, int bodyLength) {
  packet.cc = in.readShort();//read cc
  packet.flags = in.readByte();//read flags
  packet.sessionId = in.readInt();//read sessionId
  packet.lrc = in.readByte();//read lrc
  //read body
  if (bodyLength > 0) {
    in.readBytes(packet.body = new byte[bodyLength]);
  }
  return packet;
}
origin: GlowstoneMC/Glowstone

private static boolean readableVarInt(ByteBuf buf) {
  if (buf.readableBytes() > 5) {
    // maximum varint size
    return true;
  }
  int idx = buf.readerIndex();
  byte in;
  do {
    if (buf.readableBytes() < 1) {
      buf.readerIndex(idx);
      return false;
    }
    in = buf.readByte();
  } while ((in & 0x80) != 0);
  buf.readerIndex(idx);
  return true;
}
origin: runelite/runelite

  @Override
  protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
  {
    if (in.getByte(in.readerIndex()) != UpdateOpcodes.ENCRYPTION)
    {
      ctx.fireChannelRead(in.retain());
      return;
    }

    in.readByte();
    byte xorKey = in.readByte();
    in.readShort(); // always 0

    EncryptionPacket encryptionPacket = new EncryptionPacket();
    encryptionPacket.setKey(xorKey);
    out.add(encryptionPacket);
  }
}
origin: waterguo/antsdb

@Override
public void read(MysqlClientHandler handler, ByteBuf in) {
  int begin = in.readerIndex();
  in.readByte();
  tableName = BufferUtils.readStringWithLength(in);
  in.readByte();
  colCount = (int)BufferUtils.readLength(in);
  colTypeDef = BufferUtils.readBytes(in, colCount);
  in.readBytes(nullBitMap);
  int end = in.readerIndex();
  if (_log.isTraceEnabled())
    in.readerIndex(begin);
    byte[] bytes = new byte[end - begin];
    in.readBytes(bytes);
    String dump = '\n' + UberUtil.hexDump(bytes);
    _log.trace("Packet Info:\n"
        + this.toString()
        + "\nTableMapPacket packet:\n" 
origin: com.whizzosoftware.foscam/foscam-camera-discovery

if (buf.isReadable()) {
  do {
    b = buf.readByte();
  } while (b != 'M' && buf.isReadable());
  if (buf.readableBytes() > 0) {
    logger.trace("Found possible start of order");
    b = buf.readByte();
    if (b == 'O' && buf.isReadable()) {
      b = buf.readByte();
      if (b == '_' && buf.isReadable()) {
        b = buf.readByte();
        if (b == 'I' && buf.isReadable()) {
          Integer operationCode = popINT16(buf);
              Integer length = popINT32(buf);
              if (length != null && popBytes(buf, 4)) {
                if (buf.readableBytes() >= length) {
                  byte[] text = new byte[length];
                  buf.readBytes(text);
origin: org.apache.plc4x/plc4j-protocol-s7

protected void decode(ChannelHandlerContext ctx, IsoTPMessage in, List<Object> out) {
  if (logger.isTraceEnabled()) {
    logger.trace("Got Data: {}", ByteBufUtil.hexDump(in.getUserData()));
  if (userData.readableBytes() == 0) {
    return;
  if (userData.readByte() != S7_PROTOCOL_MAGIC_NUMBER) {
    logger.warn("Expecting S7 protocol magic number.");
    if (logger.isDebugEnabled()) {
  MessageType messageType = MessageType.valueOf(userData.readByte());
  boolean isResponse = messageType == MessageType.ACK_DATA;
  userData.readShort();  // Reserved (is always constant 0x0000)
  short tpduReference = userData.readShort();
  short headerParametersLength = userData.readShort();
  short userDataLength = userData.readShort();
  byte errorClass = 0;
  byte errorCode = 0;
  if (isResponse) {
    errorClass = userData.readByte();
    errorCode = userData.readByte();
origin: alibaba/Sentinel

  @Override
  public ClusterResponse decode(ByteBuf source) {
    if (source.readableBytes() >= 6) {
      int xid = source.readInt();
      int type = source.readByte();
      int status = source.readByte();

      EntityDecoder<ByteBuf, ?> decoder = ResponseDataDecodeRegistry.getDecoder(type);
      if (decoder == null) {
        RecordLog.warn("Unknown type of response data decoder: {0}", type);
        return null;
      }

      Object data;
      if (source.readableBytes() == 0) {
        data = null;
      } else {
        data = decoder.decode(source);
      }

      return new ClusterResponse<>(xid, type, status, data);
    }
    return null;
  }
}
origin: weibocom/motan

@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
  if (in.readableBytes() <= MotanConstants.NETTY_HEADER) {
    return;
  }
  in.markReaderIndex();
  short type = in.readShort();
  if (type != MotanConstants.NETTY_MAGIC_TYPE) {
    in.resetReaderIndex();
    throw new MotanFrameworkException("NettyDecoder transport header not support, type: " + type);
  }
  in.skipBytes(1);
  int rpcVersion = (in.readByte() & 0xff) >>> 3;
  switch (rpcVersion) {
    case 0:
      decodeV1(ctx, in, out);
      break;
    case 1:
      decodeV2(ctx, in, out);
      break;
    default:
      decodeV2(ctx, in, out);
  }
}
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

switch (buf.readInt()) {
  case 0x20D:
    position.set(Position.KEY_RPM, value.readShortLE());
    break;
  case 0x58C:
    value.readByte();
    value.readShort(); // index
    switch (value.readByte()) {
      case 0x01:
        position.set("setpointZone1", value.readIntLE() * 0.1);
origin: alibaba/fescar

  @Override
  public boolean decode(ByteBuf in) {
    int i = in.readableBytes();
    if (i < 3) {
      return false;
    }
    i -= 3;
    this.identified = (in.readByte() == 1);

    short len = in.readShort();
    if (len > 0) {
      if (i < len) {
        return false;
      }

      byte[] bs = new byte[len];
      in.readBytes(bs);
      this.setVersion(new String(bs, UTF8));
    }

    return true;
  }
}
origin: org.opendaylight.netconf/netconf-netty-util

@Override
public void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out) throws IOException, SAXException {
  if (in.isReadable()) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("Received to decode: {}", ByteBufUtil.hexDump(in));
      if (!isWhitespace(in.readByte())) {
        in.readerIndex(in.readerIndex() - 1);
        break;
    if (in.readerIndex() != 0 && LOG.isWarnEnabled()) {
      final byte[] strippedBytes = new byte[in.readerIndex()];
      in.getBytes(0, strippedBytes, 0, in.readerIndex());
origin: whizzosoftware/WZWave

  cbuf.addComponent(previousBuf.copy());
  cbuf.addComponent(in);
  cbuf.writerIndex(previousBuf.readableBytes() + in.readableBytes());
  data = cbuf;
  if (data.readableBytes() == 1 && isSingleByteFrame(data, data.readerIndex())) {
    out.add(createSingleByteFrame(data));
  } else {
    boolean foundFrame = false;
    for (int searchStartIx = data.readerIndex(); searchStartIx < data.readerIndex() + data.readableBytes(); searchStartIx++) {
      if (data.getByte(searchStartIx) == DataFrame.START_OF_FRAME) {
        int frameEndIx = scanForFrame(data, searchStartIx);
          if (df != null) {
            out.add(df);
            data.readByte(); // discard checksum
            foundFrame = true;
          } else {
in.readBytes(in.readableBytes());
logger.trace("Done processing received data: {}", out);
origin: traccar/traccar

@Override
protected Object decode(
    ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
  if (buf.readableBytes() >= MESSAGE_HEADER) {
    int length = Integer.parseInt(buf.toString(2, 2, StandardCharsets.US_ASCII)) + 5;
    if (buf.readableBytes() >= length) {
      ByteBuf frame = buf.readRetainedSlice(length);
      while (buf.isReadable() && buf.getUnsignedByte(buf.readerIndex()) != '$') {
        buf.readByte();
      }
      return frame;
    }
  }
  return null;
}
origin: mpusher/mpush

private Packet decodeFrame(ByteBuf in) {
  int readableBytes = in.readableBytes();
  int bodyLength = in.readInt();
  if (readableBytes < (bodyLength + Packet.HEADER_LEN)) {
    return null;
  }
  if (bodyLength > maxPacketSize) {
    throw new TooLongFrameException("packet body length over limit:" + bodyLength);
  }
  return decodePacket(new Packet(in.readByte()), in, bodyLength);
}
origin: traccar/traccar

while (buf.readableBytes() > 0) {
    for (int i = 1; i < n; i++) {
      if (k == 1) {
        data.append(buf.readByte()).append(" ");
      } else if (k == 2) {
        data.append(buf.readShort()).append(" ");
    for (int i = 1; i < m; i++) {
      if (k == 1) {
        data.append(buf.readByte()).append(" ");
      } else if (k == 2) {
        data.append(buf.readShort()).append(" ");
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: runelite/runelite

@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
{
  byte opcode = in.getByte(in.readerIndex());
  if (opcode != UpdateOpcodes.ARCHIVE_REQUEST_HIGH
    && opcode != UpdateOpcodes.ARCHIVE_REQUEST_LOW)
  {
    ctx.fireChannelRead(in.retain());
    return;
  }
  byte priority = in.readByte();
  int index = in.readByte() & 0xFF;
  int archiveId = in.readShort() & 0xFFFF;
  ArchiveRequestPacket archiveRequest = new ArchiveRequestPacket();
  archiveRequest.setPriority(priority == 1);
  archiveRequest.setIndex(index);
  archiveRequest.setArchive(archiveId);
  out.add(archiveRequest);
}
origin: alibaba/Sentinel

private boolean decodeParam(ByteBuf source, List<Object> params) {
  byte paramType = source.readByte();
      params.add(source.readInt());
      return true;
    case ClusterConstants.PARAM_TYPE_STRING:
      int length = source.readInt();
      byte[] bytes = new byte[length];
      source.readBytes(bytes);
      return true;
    case ClusterConstants.PARAM_TYPE_BYTE:
      params.add(source.readByte());
      return true;
    case ClusterConstants.PARAM_TYPE_SHORT:
      params.add(source.readShort());
      return true;
    default:
origin: org.opendaylight.controller/netconf-netty-util

@Override
public void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out) throws IOException, SAXException {
  if (in.isReadable()) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("Received to decode: {}", ByteBufUtil.hexDump(in));
      if (!isWhitespace(in.readByte())) {
        in.readerIndex(in.readerIndex() - 1);
        break;
    if (in.readerIndex() != 0 && LOG.isWarnEnabled()) {
      final byte[] strippedBytes = new byte[in.readerIndex()];
      in.getBytes(0, strippedBytes, 0, in.readerIndex());
io.netty.bufferByteBufreadByte

Javadoc

Gets a byte at the current readerIndex and increases the readerIndex by 1 in this buffer.

Popular methods of ByteBuf

  • readableBytes
    Returns the number of readable bytes which is equal to (this.writerIndex - this.readerIndex).
  • writeBytes
    Transfers the specified source array's data to this buffer starting at the current writerIndex and i
  • readBytes
    Transfers this buffer's data to the specified destination starting at the current readerIndex and in
  • release
  • readerIndex
  • writeByte
    Sets the specified byte at the current writerIndexand increases the writerIndex by 1 in this buffer.
  • writeInt
    Sets the specified 32-bit integer at the current writerIndexand increases the writerIndex by 4 in th
  • readInt
    Gets a 32-bit integer at the current readerIndexand increases the readerIndex by 4 in this buffer.
  • toString
    Decodes this buffer's readable bytes into a string with the specified character set name. This metho
  • retain
  • writerIndex
    Sets the writerIndex of this buffer.
  • isReadable
    Returns true if and only if this buffer contains equal to or more than the specified number of eleme
  • writerIndex,
  • isReadable,
  • writeLong,
  • writeShort,
  • skipBytes,
  • readLong,
  • array,
  • nioBuffer,
  • resetReaderIndex

Popular in Java

  • Updating database using SQL prepared statement
  • putExtra (Intent)
  • orElseThrow (Optional)
  • onCreateOptionsMenu (Activity)
  • Kernel (java.awt.image)
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Table (org.hibernate.mapping)
    A relational table
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registery of org.quartz
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.This exception may include information for locating the er
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now