LengthFieldBasedFrameDecoder

public final class LengthFieldBasedFrameDecoder : ByteToMessageDecoder

A decoder that splits the received ByteBuffer by the number of bytes specified in a fixed length header contained within the buffer. For example, if you received the following four fragmented packets: +—+—-+——+—-+ | A | BC | DEFG | HI | +—+—-+——+—-+

Given that the specified header length is 1 byte, where the first header specifies 3 bytes while the second header specifies 4 bytes, a LengthFieldBasedFrameDecoder will decode them into the following packets:

+-----+------+
| BCD | FGHI |
+-----+------+

‘A’ and ‘E’ will be the headers and will not be passed forward.

  • An enumeration to describe the length of a piece of data in bytes. It is contained to lengths that can be converted to integer types.

    See more

    Declaration

    Swift

    public enum ByteLength
  • Undocumented

    Declaration

    Swift

    public typealias InboundIn = ByteBuffer
  • Declaration

    Swift

    public typealias InboundOut = ByteBuffer
  • Undocumented

    Declaration

    Swift

    public var cumulationBuffer: ByteBuffer?
  • Create LengthFieldBasedFrameDecoder with a given frame length.

    Declaration

    Swift

    public init(lengthFieldLength: ByteLength, lengthFieldEndianness: Endianness = .big)

    Parameters

    lengthFieldLength

    The length of the field specifying the remaining length of the frame.

    lengthFieldEndianness

    The endianness of the field specifying the remaining length of the frame.

  • Declaration

    Swift

    public func decode(context: ChannelHandlerContext, buffer: inout ByteBuffer) throws -> DecodingState
  • Declaration

    Swift

    public func decodeLast(context: ChannelHandlerContext, buffer: inout ByteBuffer, seenEOF: Bool) throws -> DecodingState