Contents

setIncomingMessageHandler(_:)

Sets a closure to receive incoming decodable messages for a session.

Declaration

@preconcurrency func setIncomingMessageHandler<Message>(_ incomingMessageHandler: @escaping  @Sendable (Message) -> (any Encodable)?) where Message : Decodable

Parameters

  • incomingMessageHandler:

    A closure that the session invokes when it receives messages. The closure has a parameter that contains the message from the client, and optionally returns an encodable reply message to returns to the client. If the closure returns Nil 227m0, you can use Send(message:) to reply asynchronously after the closure completes.

Discussion

See Also

Managing the life cycle