_ChannelInboundHandler

public protocol _ChannelInboundHandler : ChannelHandler

Untyped ChannelHandler which handles inbound I/O events.

Despite the fact that channelRead is one of the methods on this protocol, you should avoid assuming that inbound events are to do with reading from channel sources. Instead, inbound events are events that originate from the channel source (e.g. the socket): that is, events that the channel source tells you about. This includes things like channelRead (there is some data to read), but it also includes things like channelWritabilityChanged (this source is no longer marked writable).

We strongly advise against implementing this protocol directly. Please implement ChannelInboundHandler.

  • channelRegistered(ctx:) Default implementation

    Called when the Channel has successfully registered with its EventLoop to handle I/O.

    This should call ctx.fireChannelRegistered to forward the operation to the next _ChannelInboundHandler in the ChannelPipeline if you want to allow the next handler to also handle the event.

    Default Implementation

    Declaration

    Swift

    func channelRegistered(ctx: ChannelHandlerContext)

    Parameters

    ctx

    The ChannelHandlerContext which this ChannelHandler belongs to.

  • channelUnregistered(ctx:) Default implementation

    Called when the Channel has unregistered from its EventLoop, and so will no longer be receiving I/O events.

    This should call ctx.fireChannelUnregistered to forward the operation to the next _ChannelInboundHandler in the ChannelPipeline if you want to allow the next handler to also handle the event.

    Default Implementation

    Declaration

    Swift

    func channelUnregistered(ctx: ChannelHandlerContext)

    Parameters

    ctx

    The ChannelHandlerContext which this ChannelHandler belongs to.

  • channelActive(ctx:) Default implementation

    Called when the Channel has become active, and is able to send and receive data.

    This should call ctx.fireChannelActive to forward the operation to the next _ChannelInboundHandler in the ChannelPipeline if you want to allow the next handler to also handle the event.

    Default Implementation

    Declaration

    Swift

    func channelActive(ctx: ChannelHandlerContext)

    Parameters

    ctx

    The ChannelHandlerContext which this ChannelHandler belongs to.

  • channelInactive(ctx:) Default implementation

    Called when the Channel has become inactive and is no longer able to send and receive data`.

    This should call ctx.fireChannelInactive to forward the operation to the next _ChannelInboundHandler in the ChannelPipeline if you want to allow the next handler to also handle the event.

    Default Implementation

    Declaration

    Swift

    func channelInactive(ctx: ChannelHandlerContext)

    Parameters

    ctx

    The ChannelHandlerContext which this ChannelHandler belongs to.

  • channelRead(ctx:data:) Default implementation

    Called when some data has been read from the remote peer.

    This should call ctx.fireChannelRead to forward the operation to the next _ChannelInboundHandler in the ChannelPipeline if you want to allow the next handler to also handle the event.

    Default Implementation

    Declaration

    Swift

    func channelRead(ctx: ChannelHandlerContext, data: NIOAny)

    Parameters

    ctx

    The ChannelHandlerContext which this ChannelHandler belongs to.

    data

    The data read from the remote peer, wrapped in a NIOAny.

  • channelReadComplete(ctx:) Default implementation

    Called when the Channel has completed its current read loop, either because no more data is available to read from the transport at this time, or because the Channel needs to yield to the event loop to process other I/O events for other Channels. If ChannelOptions.autoRead is false no further read attempt will be made until ChannelHandlerContext.read or Channel.read is explicitly called.

    This should call ctx.fireChannelReadComplete to forward the operation to the next _ChannelInboundHandler in the ChannelPipeline if you want to allow the next handler to also handle the event.

    Default Implementation

    Declaration

    Swift

    func channelReadComplete(ctx: ChannelHandlerContext)

    Parameters

    ctx

    The ChannelHandlerContext which this ChannelHandler belongs to.

  • channelWritabilityChanged(ctx:) Default implementation

    The writability state of the Channel has changed, either because it has buffered more data than the writability high water mark, or because the amount of buffered data has dropped below the writability low water mark. You can check the state with Channel.isWritable.

    This should call ctx.fireChannelWritabilityChanged to forward the operation to the next _ChannelInboundHandler in the ChannelPipeline if you want to allow the next handler to also handle the event.

    Default Implementation

    Declaration

    Swift

    func channelWritabilityChanged(ctx: ChannelHandlerContext)

    Parameters

    ctx

    The ChannelHandlerContext which this ChannelHandler belongs to.

  • userInboundEventTriggered(ctx:event:) Default implementation

    Called when a user inbound event has been triggered.

    This should call ctx.fireUserInboundEventTriggered to forward the operation to the next _ChannelInboundHandler in the ChannelPipeline if you want to allow the next handler to also handle the event.

    Default Implementation

    Declaration

    Swift

    func userInboundEventTriggered(ctx: ChannelHandlerContext, event: Any)

    Parameters

    ctx

    The ChannelHandlerContext which this ChannelHandler belongs to.

    event

    The event.

  • errorCaught(ctx:error:) Default implementation

    An error was encountered earlier in the inbound ChannelPipeline.

    This should call ctx.fireErrorCaught to forward the operation to the next _ChannelInboundHandler in the ChannelPipeline if you want to allow the next handler to also handle the error.

    Default Implementation

    Declaration

    Swift

    func errorCaught(ctx: ChannelHandlerContext, error: Error)

    Parameters

    ctx

    The ChannelHandlerContext which this ChannelHandler belongs to.

    error

    The Error that was encountered.