ByteToMessageHandler

    A handler which turns a given ByteToMessageDecoder into a ChannelInboundHandler that can then be added to a ChannelPipeline.

    Codec.swift:388
    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

      ByteToMessageDecoders decode bytes in a stream-like fashion from ByteBuffer to another message type.

    • protocol WriteObservingByteToMessageDecoder

      Some ByteToMessageDecoders need to observe writes (which are outbound events). ByteToMessageDecoders which implement the WriteObservingByteToMessageDecoder 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 of decode or decodeLast. Having decode and decodeLast return an optional message avoids re-entrancy problems, since the functions relinquish exclusive access to the ByteBuffer when returning. This allows for greatly simplified processing.

    • class NIOSingleStepByteToMessageProcessor<Decoder>

      NIOSingleStepByteToMessageProcessor uses a NIOSingleStepByteToMessageDecoder to produce messages from a stream of incoming bytes. It works like ByteToMessageHandler 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 ByteBuffers. To add a MessageToByteEncoder to a ChannelPipeline, use channel.pipeline.addHandler(MessageToByteHandler(myEncoder).

    • class MessageToByteHandler<Encoder>

      A handler which turns a given MessageToByteEncoder into a ChannelOutboundHandler that can then be added to a ChannelPipeline.

    Citizens in NIOCore

    Typealiases

    Type members

    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 a Channel.

    • protocol RemovableChannelHandler

      A RemovableChannelHandler is a ChannelHandler that can be dynamically removed from a ChannelPipeline whilst the Channel is operating normally. A RemovableChannelHandler is required to remove itself from the ChannelPipeline (using ChannelHandlerContext.leavePipeline) as soon as possible.

    Show implementation details (2)

    Hide implementation details

    Instance members

    Instance features

    Citizens in NIOCore

    Conformances

    Show implementation details (1)

    Hide implementation details

    Typealiases

    Instance members

    Instance features