-
Returns the local bound
SocketAddress
.Declaration
Swift
func localAddress0() throws -> SocketAddress
-
Return the connected
SocketAddress
.Declaration
Swift
func remoteAddress0() throws -> SocketAddress
-
Register with the
EventLoop
to receive I/O notifications.Declaration
Swift
func register0(promise: EventLoopPromise<Void>?)
Parameters
promise
The
EventLoopPromise
which should be notified once the operation completes, or nil if no notification should take place. -
Register channel as already connected or bound socket.
Declaration
Swift
func registerAlreadyConfigured0(promise: EventLoopPromise<Void>?)
Parameters
promise
The
EventLoopPromise
which should be notified once the operation completes, or nil if no notification should take place. -
Bind to a
SocketAddress
.Declaration
Swift
func bind0(to: SocketAddress, promise: EventLoopPromise<Void>?)
Parameters
to
The
SocketAddress
to which we should bind theChannel
.promise
The
EventLoopPromise
which should be notified once the operation completes, or nil if no notification should take place. -
Connect to a
SocketAddress
.Declaration
Swift
func connect0(to: SocketAddress, promise: EventLoopPromise<Void>?)
Parameters
to
The
SocketAddress
to which we should connect theChannel
.promise
The
EventLoopPromise
which should be notified once the operation completes, or nil if no notification should take place. -
Write the given data to the outbound buffer.
Declaration
Swift
func write0(_ data: NIOAny, promise: EventLoopPromise<Void>?)
Parameters
data
The data to write, wrapped in a
NIOAny
.promise
The
EventLoopPromise
which should be notified once the operation completes, or nil if no notification should take place. -
Try to flush out all previous written messages that are pending.
Declaration
Swift
func flush0()
-
Request that the
Channel
perform a read when data is ready.Declaration
Swift
func read0()
-
Close the
Channel
.Declaration
Swift
func close0(error: Error, mode: CloseMode, promise: EventLoopPromise<Void>?)
Parameters
error
The
Error
which will be used to fail any pending writes.mode
The
CloseMode
to apply.promise
The
EventLoopPromise
which should be notified once the operation completes, or nil if no notification should take place. -
Trigger an outbound event.
Declaration
Swift
func triggerUserOutboundEvent0(_ event: Any, promise: EventLoopPromise<Void>?)
Parameters
event
The triggered event.
promise
The
EventLoopPromise
which should be notified once the operation completes, or nil if no notification should take place. -
Called when data was read from the
Channel
but it was not consumed by anyChannelInboundHandler
in theChannelPipeline
.Declaration
Swift
func channelRead0(_ data: NIOAny)
Parameters
data
The data that was read, wrapped in a
NIOAny
. -
Called when an inbound error was encountered but was not consumed by any
ChannelInboundHandler
in theChannelPipeline
.Declaration
Swift
func errorCaught0(error: Error)
Parameters
error
The
Error
that was encountered. -
unwrapData(_:
Extension methodas: ) Unwraps the given
NIOAny
as a specific concrete type.This method is intended for use when writing custom
ChannelCore
implementations. This can safely be called in methods likewrite0
to extract data from theNIOAny
provided in those cases.Note that if the unwrap fails, this will cause a runtime trap.
ChannelCore
implementations should be concrete about what types they support writing. If multiple types are supported, considere using a tagged union to store the type information like NIO’s ownIOData
, which will minimise the amount of runtime type checking.Declaration
Swift
@inlinable public func unwrapData<T>(_ data: NIOAny, as: T.Type = T.self) -> T
Return Value
The content of the
NIOAny
. -
removeHandlers(channel:
Extension method) Removes the
ChannelHandler
s from theChannelPipeline
belonging tochannel
, and closes thatChannelPipeline
.This method is intended for use when writing custom
ChannelCore
implementations. This can be called fromclose0
to tear down theChannelPipeline
when closure is complete.Declaration
Swift
public func removeHandlers(channel: Channel)
Parameters
channel
The
Channel
whoseChannelPipeline
will be closed.