public class ApplicationProtocolNegotiationHandler : ChannelInboundHandler
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
The user of this channel handler provides a single closure that is called with
ALPNResult when the ALPN negotiation is complete. Based on that result
the user is free to reconfigure the
ChannelPipeline as required, and should
EventLoopFuture that will complete when the pipeline is reconfigured.
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
ApplicationProtocolNegotiationHandlerwith the given completion callback.
public init(alpnCompleteHandler: @escaping (ALPNResult) -> EventLoopFuture<Void>)
The closure that will fire when ALPN negotiation has completed.
public func userInboundEventTriggered(ctx: ChannelHandlerContext, event: Any)
public func channelRead(ctx: ChannelHandlerContext, data: NIOAny)