ChannelOutboundInvoker

public protocol ChannelOutboundInvoker

Allows users to invoke an outbound operation related to a Channel that will flow through the ChannelPipeline until it will finally be executed by the the ChannelCore implementation.

  • Register on an EventLoop and so have all its IO handled.

    Declaration

    Swift

    func register(promise: EventLoopPromise<Void>?)

    Parameters

    promise

    the EventLoopPromise that will be notified once the operation completes, or nil if not interested in the outcome of the operation.

  • Bind to a SocketAddress.

    Declaration

    Swift

    func bind(to: SocketAddress, promise: EventLoopPromise<Void>?)

    Parameters

    to

    the SocketAddress to which we should bind the Channel.

    promise

    the EventLoopPromise that will be notified once the operation completes, or nil if not interested in the outcome of the operation.

  • Connect to a SocketAddress.

    Declaration

    Swift

    func connect(to: SocketAddress, promise: EventLoopPromise<Void>?)

    Parameters

    to

    the SocketAddress to which we should connect the Channel.

    promise

    the EventLoopPromise that will be notified once the operation completes, or nil if not interested in the outcome of the operation.

  • Write data to the remote peer.

    Be aware that to be sure that data is really written to the remote peer you need to call flush or use writeAndFlush. Calling write multiple times and then flush may allow the Channel to write multiple data objects to the remote peer with one syscall.

    Declaration

    Swift

    func write(_ data: NIOAny, promise: EventLoopPromise<Void>?)

    Parameters

    data

    the data to write

    promise

    the EventLoopPromise that will be notified once the operation completes, or nil if not interested in the outcome of the operation.

  • Flush data that was previously written via write to the remote peer.

    Declaration

    Swift

    func flush()
  • Shortcut for calling write and flush.

    Declaration

    Swift

    func writeAndFlush(_ data: NIOAny, promise: EventLoopPromise<Void>?)

    Parameters

    data

    the data to write

    promise

    the EventLoopPromise that will be notified once the write operation completes, or nil if not interested in the outcome of the operation.

  • Signal that we want to read from the Channel once there is data ready.

    If ChannelOptions.autoRead is set for a Channel (which is the default) this method is automatically invoked by the transport implementation, otherwise it’s the user’s responsibility to call this method manually once new data should be read and processed.

    Declaration

    Swift

    func read()
  • Close the Channel and so the connection if one exists.

    Declaration

    Swift

    func close(mode: CloseMode, promise: EventLoopPromise<Void>?)

    Parameters

    mode

    the CloseMode that is used

    promise

    the EventLoopPromise that will be notified once the operation completes, or nil if not interested in the outcome of the operation.

  • Trigger a custom user outbound event which will flow through the ChannelPipeline.

    Declaration

    Swift

    func triggerUserOutboundEvent(_ event: Any, promise: EventLoopPromise<Void>?)

    Parameters

    promise

    the EventLoopPromise that will be notified once the operation completes, or nil if not interested in the outcome of the operation.

  • The EventLoop which is used by this ChannelOutboundInvoker for execution.

    Declaration

    Swift

    var eventLoop: EventLoop { get }
  • register(file:line:) Extension method

    Register on an EventLoop and so have all its IO handled.

    Declaration

    Swift

    public func register(file: StaticString = #file, line: UInt = #line) -> EventLoopFuture<Void>

    Return Value

    the future which will be notified once the operation completes.

  • bind(to:file:line:) Extension method

    Bind to a SocketAddress.

    Declaration

    Swift

    public func bind(to address: SocketAddress, file: StaticString = #file, line: UInt = #line) -> EventLoopFuture<Void>

    Parameters

    to

    the SocketAddress to which we should bind the Channel.

    Return Value

    the future which will be notified once the operation completes.

  • connect(to:file:line:) Extension method

    Connect to a SocketAddress.

    Declaration

    Swift

    public func connect(to address: SocketAddress, file: StaticString = #file, line: UInt = #line) -> EventLoopFuture<Void>

    Parameters

    to

    the SocketAddress to which we should connect the Channel.

    Return Value

    the future which will be notified once the operation completes.

  • write(_:file:line:) Extension method

    Write data to the remote peer.

    Be aware that to be sure that data is really written to the remote peer you need to call flush or use writeAndFlush. Calling write multiple times and then flush may allow the Channel to write multiple data objects to the remote peer with one syscall.

    Declaration

    Swift

    public func write(_ data: NIOAny, file: StaticString = #file, line: UInt = #line) -> EventLoopFuture<Void>

    Parameters

    data

    the data to write

    Return Value

    the future which will be notified once the operation completes.

  • writeAndFlush(_:file:line:) Extension method

    Shortcut for calling write and flush.

    Declaration

    Swift

    public func writeAndFlush(_ data: NIOAny, file: StaticString = #file, line: UInt = #line) -> EventLoopFuture<Void>

    Parameters

    data

    the data to write

    Return Value

    the future which will be notified once the write operation completes.

  • close(mode:file:line:) Extension method

    Close the Channel and so the connection if one exists.

    Declaration

    Swift

    public func close(mode: CloseMode = .all, file: StaticString = #file, line: UInt = #line) -> EventLoopFuture<Void>

    Parameters

    mode

    the CloseMode that is used

    Return Value

    the future which will be notified once the operation completes.

  • Trigger a custom user outbound event which will flow through the ChannelPipeline.

    Declaration

    Swift

    public func triggerUserOutboundEvent(_ event: Any, file: StaticString = #file, line: UInt = #line) -> EventLoopFuture<Void>

    Parameters

    event

    the event itself.

    Return Value

    the future which will be notified once the operation completes.