Interface InputChannel


public interface InputChannel
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Must be called before calling readAsync().
    io.netty.buffer.ByteBuf
    Can only be called is isReadable has returned true.
    io.netty.buffer.ByteBuf
    Reads some data.
    int
     
    <T> void
    setReadHandler(BiConsumer<InputChannel,T> handler, T context)
    Registers a read handler that will be called when the channel is readable.
  • Method Details

    • readAsync

      io.netty.buffer.ByteBuf readAsync() throws IOException
      Can only be called is isReadable has returned true. If there is data this will return a buffer, otherwise it will return null to indicate EOF
      Throws:
      IOException
    • isReadable

      boolean isReadable()
      Must be called before calling readAsync(). If this returns true then data can be read, if this returns false then a read handler can be registered using setReadHandler(BiConsumer, Object)
      Returns:
      true if data can be read
    • setReadHandler

      <T> void setReadHandler(BiConsumer<InputChannel,T> handler, T context)
      Registers a read handler that will be called when the channel is readable. This handler will only be called once, to continue to read this method must be called every time isReadable() returns false
      Type Parameters:
      T - The type of the context object
      Parameters:
      handler - The handler
      context - A context object that will be passed to the handler
    • readBytesAvailable

      int readBytesAvailable()
      Returns:
      The number of bytes that are available to be immediately read
    • readBlocking

      io.netty.buffer.ByteBuf readBlocking() throws IOException
      Reads some data. If all data has been read it will return null.
      Returns:
      Throws:
      IOException - on failure