NIOSSLHandler

public class NIOSSLHandler : ChannelInboundHandler, ChannelOutboundHandler, RemovableChannelHandler

The base class for all NIOSSL handlers. This class cannot actually be instantiated by users directly: instead, users must select which mode they would like their handler to operate in, client or server.

This class exists to deal with the reality that for almost the entirety of the lifetime of a TLS connection there is no meaningful distinction between a server and a client. For this reason almost the entirety of the implementation for the channel and server handlers in NIOSSL is shared, in the form of this parent class.

  • Declaration

    Swift

    public typealias OutboundIn = ByteBuffer
  • Declaration

    Swift

    public typealias OutboundOut = ByteBuffer
  • Declaration

    Swift

    public typealias InboundIn = ByteBuffer
  • Declaration

    Swift

    public typealias InboundOut = ByteBuffer
  • Declaration

    Swift

    public func handlerAdded(context: ChannelHandlerContext)
  • Declaration

    Swift

    public func handlerRemoved(context: ChannelHandlerContext)
  • Get the connection to drop any state it might have. This state can cause reference cycles, so we need to break those when we know it’s safe to do so. This is a good safe point, as no further I/O can possibly occur.

    Declaration

    Swift

    public func channelActive(context: ChannelHandlerContext)
  • Declaration

    Swift

    public func channelInactive(context: ChannelHandlerContext)
  • Declaration

    Swift

    public func channelRead(context: ChannelHandlerContext, data: NIOAny)
  • Declaration

    Swift

    public func channelReadComplete(context: ChannelHandlerContext)
  • Declaration

    Swift

    public func write(context: ChannelHandlerContext, data: NIOAny, promise: EventLoopPromise<Void>?)
  • Declaration

    Swift

    public func flush(context: ChannelHandlerContext)
  • Declaration

    Swift

    public func close(context: ChannelHandlerContext, mode: CloseMode, promise: EventLoopPromise<Void>?)
  • Called to instruct this handler to perform an orderly TLS shutdown and then remove itself from the pipeline. This will leave the connection established, but remove the TLS wrapper from it.

    This will send a CLOSE_NOTIFY and wait for the corresponding CLOSE_NOTIFY. When that next CLOSE_NOTIFY is received, this handler will pass on all pending writes and remove itself from the channel pipeline. If the shutdown times out then an error will fire down the pipeline, this handler will remove itself from the pipeline, but the channel will not be automatically closed.

    This function is not thread-safe: you must call it from the correct event loop thread.

    Declaration

    Swift

    public func stopTLS(promise: EventLoopPromise<Void>?)

    Parameters

    promise

    An EventLoopPromise that will be completed when the unwrapping has completed.