public final class WebSocketFrameDecoder : ByteToMessageDecoder
ChannelHandler that deserializes websocket frames into a structured
format for further processing.
This decoder has limited enforcement of compliance to RFC 6455. In particular, to guarantee that the decoder can handle arbitrary extensions, only normative MUST/MUST NOTs that do not relate to extensions (e.g. the requirement that control frames not have lengths larger than 125 bytes) are enforced by this decoder.
This decoder does not have any support for decoding extensions. If you wish to support extensions, you should implement a message-to-message decoder that performs the appropriate frame transformation as needed. All the frame data is assumed to be application data by this parser.
public typealias InboundIn = ByteBuffer
Construct a new
public init(maxFrameSize: Int = 1 << 14)
The maximum frame size the decoder is willing to tolerate from the remote peer. WebSockets in principle allows frame sizes up to
2**64bytes, but this is an objectively unreasonable maximum value (on AMD64 systems it is not possible to even allocate a buffer large enough to handle this size), so we set a lower one. The default value is the same as the default HTTP/2 max frame size,
2**14bytes. Users may override this to any value up to
UInt32.max. Users are strongly encouraged not to increase this value unless they absolutely must, as the decoder will not produce partial frames, meaning that it will hold on to data until the entire body is received.
ChannelHandlershould automatically handle protocol errors in frame serialization, or whether it should allow the pipeline to handle them.
public func decode(context: ChannelHandlerContext, buffer: inout ByteBuffer) throws -> DecodingState