ByteToMessageHandler
public final class ByteToMessageHandler<Decoder> where Decoder : ByteToMessageDecoder
extension ByteToMessageHandler: ChannelInboundHandler
extension ByteToMessageHandler: RemovableChannelHandler
extension ByteToMessageHandler: ChannelOutboundHandler, _ChannelOutboundHandler where Decoder: WriteObservingByteToMessageDecoder
A handler which turns a given ByteToMessageDecoder
into a ChannelInboundHandler
that can then be added to a
ChannelPipeline
.
Most importantly, ByteToMessageHandler
handles the tricky buffer management for you and flattens out all
re-entrancy on channelRead
that may happen in the ChannelPipeline
.
-
Declaration
Swift
public typealias InboundIn = ByteBuffer
-
Declaration
Swift
public typealias InboundOut = Decoder.InboundOut
-
@see: ByteToMessageHandler.init(_:maximumBufferSize)
Declaration
Swift
public convenience init(_ decoder: Decoder)
-
Initialize a
ByteToMessageHandler
.Declaration
Swift
public init(_ decoder: Decoder, maximumBufferSize: Int? = nil)
Parameters
decoder
The
ByteToMessageDecoder
to decode the bytes into message.maximumBufferSize
The maximum number of bytes to aggregate in-memory.
-
Declaration
Swift
public func handlerAdded(context: ChannelHandlerContext)
-
Declaration
Swift
public func handlerRemoved(context: ChannelHandlerContext)
-
Calls
decode
until there is nothing left to decode.Declaration
Swift
public func channelRead(context: ChannelHandlerContext, data: NIOAny)
-
Call
decodeLast
before forward the event through the pipeline.Declaration
Swift
public func channelInactive(context: ChannelHandlerContext)
-
Declaration
Swift
public func userInboundEventTriggered(context: ChannelHandlerContext, event: Any)
-
Declaration
Swift
public func removeHandler(context: ChannelHandlerContext, removalToken: ChannelHandlerContext.RemovalToken)
-
Declaration
Swift
public typealias OutboundIn = Decoder.OutboundIn
-
Declaration
Swift
public func write(context: ChannelHandlerContext, data: NIOAny, promise: EventLoopPromise<Void>?)