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, ornil
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 theChannel
.promise
the
EventLoopPromise
that will be notified once the operation completes, ornil
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 theChannel
.promise
the
EventLoopPromise
that will be notified once the operation completes, ornil
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 usewriteAndFlush
. Callingwrite
multiple times and thenflush
may allow theChannel
towrite
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, ornil
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
andflush
.Declaration
Swift
func writeAndFlush(_ data: NIOAny, promise: EventLoopPromise<Void>?)
Parameters
data
the data to write
promise
the
EventLoopPromise
that will be notified once thewrite
operation completes, ornil
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 aChannel
(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 usedpromise
the
EventLoopPromise
that will be notified once the operation completes, ornil
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, ornil
if not interested in the outcome of the operation. -
register(file:
Extension methodline: ) 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:
Extension methodfile: line: ) 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 theChannel
.Return Value
the future which will be notified once the operation completes.
-
connect(to:
Extension methodfile: line: ) 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 theChannel
.Return Value
the future which will be notified once the operation completes.
-
write(_:
Extension methodfile: line: ) 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 usewriteAndFlush
. Callingwrite
multiple times and thenflush
may allow theChannel
towrite
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(_:
Extension methodfile: line: ) Shortcut for calling
write
andflush
.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:
Extension methodfile: line: ) 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 usedReturn Value
the future which will be notified once the operation completes.
-
triggerUserOutboundEvent(_:
Extension methodfile: line: ) 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.