Interface NioChannelHandler

All Known Implementing Classes:
BytesWriteHandler, DelegatingHandler

public interface NioChannelHandler
Implements the application specific logic for handling channel operations.
  • Method Details

    • channelActive

      void channelActive()
      This method is called when the channel is active for use.
    • createWriteOperation

      WriteOperation createWriteOperation(SocketChannelContext context, Object message, BiConsumer<Void,Exception> listener)
      This method is called when a message is queued with a channel. It can be called from any thread. This method should validate that the message is a valid type and return a write operation object to be queued with the channel
      Parameters:
      context - the channel context
      message - the message
      listener - the listener to be called when the message is sent
      Returns:
      the write operation to be queued
    • writeToBytes

      List<FlushOperation> writeToBytes(WriteOperation writeOperation)
      This method is called on the event loop thread. It should serialize a write operation object to bytes that can be flushed to the raw nio channel.
      Parameters:
      writeOperation - to be converted to bytes
      Returns:
      the operations to flush the bytes to the channel
    • pollFlushOperations

      List<FlushOperation> pollFlushOperations()
      Returns any flush operations that are ready to flush. This exists as a way to check if any flush operations were produced during a read call.
      Returns:
      flush operations
    • consumeReads

      int consumeReads(InboundChannelBuffer channelBuffer) throws IOException
      This method handles bytes that have been read from the network. It should return the number of bytes consumed so that they can be released.
      Parameters:
      channelBuffer - of bytes read from the network
      Returns:
      the number of bytes consumed
      Throws:
      IOException - if an exception occurs
    • closeNow

      boolean closeNow()
      This method indicates if the underlying channel should be closed.
      Returns:
      if the channel should be closed
    • close

      void close() throws IOException
      Throws:
      IOException