Classes

The following classes are available globally.

  • A helper ChannelInboundHandler that makes it easy to swap channel pipelines based on the result of an ALPN negotiation.

    The standard pattern used by applications that want to use ALPN is to select an application protocol based on the result, optionally falling back to some default protocol. To do this in SwiftNIO requires that the channel pipeline be reconfigured based on the result of the ALPN negotiation. This channel handler encapsulates that logic in a generic form that doesn’t depend on the specific TLS implementation in use by using TLSUserEvent

    The user of this channel handler provides a single closure that is called with an ALPNResult when the ALPN negotiation is complete. Based on that result the user is free to reconfigure the ChannelPipeline as required, and should return an EventLoopFuture that will complete when the pipeline is reconfigured.

    Until the EventLoopFuture completes, this channel handler will buffer inbound data. When the EventLoopFuture completes, the buffered data will be replayed down the channel. Then, finally, this channel handler will automatically remove itself from the channel pipeline, leaving the pipeline in its final configuration.

    See more

    Declaration

    Swift

    public class ApplicationProtocolNegotiationHandler : ChannelInboundHandler
  • A channel handler that can be used to arbitrarily edit a channel pipeline based on the hostname requested in the Server Name Indication portion of the TLS Client Hello.

    This handler is most commonly used when configuring TLS, to control which certificates are going to be shown to the client. It can also be used to ensure that only the resources required to serve a given virtual host are actually present in the channel pipeline.

    This handler does not depend on any specific TLS implementation. Instead, it parses the Client Hello itself, directly. This allows it to be generic across all possible TLS backends that can be used with NIO. It also allows for the pipeline change to be done asynchronously, providing more flexibility about how the user configures the pipeline.

    See more

    Declaration

    Swift

    public class SniHandler : ByteToMessageDecoder