_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(context:
Default implementation) Called when the
Channel
has successfully registered with itsEventLoop
to handle I/O.This should call
context.fireChannelRegistered
to forward the operation to the next_ChannelInboundHandler
in theChannelPipeline
if you want to allow the next handler to also handle the event.Default Implementation
Declaration
Swift
func channelRegistered(context: ChannelHandlerContext)
Parameters
context
The
ChannelHandlerContext
which thisChannelHandler
belongs to. -
channelUnregistered(context:
Default implementation) Called when the
Channel
has unregistered from itsEventLoop
, and so will no longer be receiving I/O events.This should call
context.fireChannelUnregistered
to forward the operation to the next_ChannelInboundHandler
in theChannelPipeline
if you want to allow the next handler to also handle the event.Default Implementation
Declaration
Swift
func channelUnregistered(context: ChannelHandlerContext)
Parameters
context
The
ChannelHandlerContext
which thisChannelHandler
belongs to. -
channelActive(context:
Default implementation) Called when the
Channel
has become active, and is able to send and receive data.This should call
context.fireChannelActive
to forward the operation to the next_ChannelInboundHandler
in theChannelPipeline
if you want to allow the next handler to also handle the event.Default Implementation
Declaration
Swift
func channelActive(context: ChannelHandlerContext)
Parameters
context
The
ChannelHandlerContext
which thisChannelHandler
belongs to. -
channelInactive(context:
Default implementation) Called when the
Channel
has become inactive and is no longer able to send and receive data`.This should call
context.fireChannelInactive
to forward the operation to the next_ChannelInboundHandler
in theChannelPipeline
if you want to allow the next handler to also handle the event.Default Implementation
Declaration
Swift
func channelInactive(context: ChannelHandlerContext)
Parameters
context
The
ChannelHandlerContext
which thisChannelHandler
belongs to. -
channelRead(context:
Default implementationdata: ) Called when some data has been read from the remote peer.
This should call
context.fireChannelRead
to forward the operation to the next_ChannelInboundHandler
in theChannelPipeline
if you want to allow the next handler to also handle the event.Default Implementation
Declaration
Swift
func channelRead(context: ChannelHandlerContext, data: NIOAny)
Parameters
context
The
ChannelHandlerContext
which thisChannelHandler
belongs to.data
The data read from the remote peer, wrapped in a
NIOAny
. -
channelReadComplete(context:
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 theChannel
needs to yield to the event loop to process other I/O events for otherChannel
s. IfChannelOptions.autoRead
isfalse
no further read attempt will be made untilChannelHandlerContext.read
orChannel.read
is explicitly called.This should call
context.fireChannelReadComplete
to forward the operation to the next_ChannelInboundHandler
in theChannelPipeline
if you want to allow the next handler to also handle the event.Default Implementation
Declaration
Swift
func channelReadComplete(context: ChannelHandlerContext)
Parameters
context
The
ChannelHandlerContext
which thisChannelHandler
belongs to. -
channelWritabilityChanged(context:
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 withChannel.isWritable
.This should call
context.fireChannelWritabilityChanged
to forward the operation to the next_ChannelInboundHandler
in theChannelPipeline
if you want to allow the next handler to also handle the event.Default Implementation
Declaration
Swift
func channelWritabilityChanged(context: ChannelHandlerContext)
Parameters
context
The
ChannelHandlerContext
which thisChannelHandler
belongs to. -
userInboundEventTriggered(context:
Default implementationevent: ) Called when a user inbound event has been triggered.
This should call
context.fireUserInboundEventTriggered
to forward the operation to the next_ChannelInboundHandler
in theChannelPipeline
if you want to allow the next handler to also handle the event.Default Implementation
Declaration
Swift
func userInboundEventTriggered(context: ChannelHandlerContext, event: Any)
Parameters
context
The
ChannelHandlerContext
which thisChannelHandler
belongs to.event
The event.
-
errorCaught(context:
Default implementationerror: ) An error was encountered earlier in the inbound
ChannelPipeline
.This should call
context.fireErrorCaught
to forward the operation to the next_ChannelInboundHandler
in theChannelPipeline
if you want to allow the next handler to also handle the error.Default Implementation
Declaration
Swift
func errorCaught(context: ChannelHandlerContext, error: Error)
Parameters
context
The
ChannelHandlerContext
which thisChannelHandler
belongs to.error
The
Error
that was encountered.