ByteToMessageHandler
A handler which turns a given ByteToMessageDecoder
into a ChannelInboundHandler
that can then be added to a ChannelPipeline
.
final class ByteToMessageHandler<Decoder> where Decoder : ByteToMessageDecoder
Most importantly, ByteToMessageHandler
handles the tricky buffer management for you and flattens out all re-entrancy on channelRead
that may happen in the ChannelPipeline
.
See also
protocol ByteToMessageDecoder
ByteToMessageDecoder
s decode bytes in a stream-like fashion fromByteBuffer
to another message type.protocol WriteObservingByteToMessageDecoder
Some
ByteToMessageDecoder
s need to observewrite
s (which are outbound events).ByteToMessageDecoder
s which implement theWriteObservingByteToMessageDecoder
protocol will be notified about every outbound write.enum DecodingState
State of the current decoding process.
protocol NIOSingleStepByteToMessageDecoder
A simplified version of
ByteToMessageDecoder
that can generate zero or one messages for each invocation ofdecode
ordecodeLast
. Havingdecode
anddecodeLast
return an optional message avoids re-entrancy problems, since the functions relinquish exclusive access to theByteBuffer
when returning. This allows for greatly simplified processing.class NIOSingleStepByteToMessageProcessor<Decoder>
NIOSingleStepByteToMessageProcessor
uses aNIOSingleStepByteToMessageDecoder
to produce messages from a stream of incoming bytes. It works likeByteToMessageHandler
but may be used outside of the channel pipeline. This allows processing of wrapped protocols in a general way.protocol MessageToByteEncoder
A protocol for straightforward encoders which encode custom messages to
ByteBuffer
s. To add aMessageToByteEncoder
to aChannelPipeline
, usechannel.pipeline.addHandler(MessageToByteHandler(myEncoder)
.class MessageToByteHandler<Encoder>
A handler which turns a given
MessageToByteEncoder
into aChannelOutboundHandler
that can then be added to aChannelPipeline
.
Citizens in NIOCore
Typealiases
Type members
init(Decoder
) init(Decoder, maximumBufferSize: Int?
) Initialize a
ByteToMessageHandler
.
Citizens in NIOCore
where Decoder:ByteToMessageDecoder
Conformances
protocol ChannelHandler
Base protocol for handlers that handle I/O events or intercept an I/O operation.
protocol ChannelInboundHandler
ChannelHandler
which handles inbound I/O events for aChannel
.protocol RemovableChannelHandler
A
RemovableChannelHandler
is aChannelHandler
that can be dynamically removed from aChannelPipeline
whilst theChannel
is operating normally. ARemovableChannelHandler
is required to remove itself from theChannelPipeline
(usingChannelHandlerContext.leavePipeline
) as soon as possible.
Show implementation details (2)
Hide implementation details
protocol _ChannelInboundHandler
Untyped
ChannelHandler
which handles inbound I/O events.protocol _EmittingChannelHandler
ChannelHandler which will emit data by calling
ChannelHandlerContext.write
.
Instance members
func channelInactive(context: ChannelHandlerContext
) Call
decodeLast
before forward the event through the pipeline.func channelRead(context: ChannelHandlerContext, data: NIOAny
) Calls
decode
until there is nothing left to decode.func handlerAdded(context: ChannelHandlerContext
) func handlerRemoved(context: ChannelHandlerContext
) func removeHandler(context: ChannelHandlerContext, removalToken: ChannelHandlerContext.RemovalToken
) func userInboundEventTriggered(context: ChannelHandlerContext, event: Any
)
Instance features
func channelActive(context: ChannelHandlerContext
) func channelReadComplete(context: ChannelHandlerContext
) func channelRegistered(context: ChannelHandlerContext
) func channelUnregistered(context: ChannelHandlerContext
) func channelWritabilityChanged(context: ChannelHandlerContext
) func errorCaught(context: ChannelHandlerContext, error: Error
) func unwrapInboundIn(NIOAny
) -> InboundIn func wrapInboundOut(InboundOut
) -> NIOAny func wrapOutboundOut(OutboundOut
) -> NIOAny
Citizens in NIOCore
where Decoder:WriteObservingByteToMessageDecoder
Conformances
protocol ChannelOutboundHandler
ChannelHandler
which handles outbound I/O events or intercept an outbound I/O operation for aChannel
.
Show implementation details (1)
Hide implementation details
protocol _ChannelOutboundHandler
Untyped
ChannelHandler
which handles outbound I/O events or intercept an outbound I/O operation.
Typealiases
Instance members
Instance features
func bind(context: ChannelHandlerContext, to: SocketAddress, promise: EventLoopPromise<Void>?
) func close(context: ChannelHandlerContext, mode: CloseMode, promise: EventLoopPromise<Void>?
) func connect(context: ChannelHandlerContext, to: SocketAddress, promise: EventLoopPromise<Void>?
) func flush(context: ChannelHandlerContext
) func read(context: ChannelHandlerContext
) func register(context: ChannelHandlerContext, promise: EventLoopPromise<Void>?
) func triggerUserOutboundEvent(context: ChannelHandlerContext, event: Any, promise: EventLoopPromise<Void>?
) func unwrapOutboundIn(NIOAny
) -> OutboundIn func write(context: ChannelHandlerContext, data: NIOAny, promise: EventLoopPromise<Void>?
)