accept(incomingMessageHandler:cancellationHandler:)
Accepts an incoming session request from a client using a closure to handle received messages, and returns the inactive session.
Declaration
@preconcurrency func accept(incomingMessageHandler: @escaping @Sendable (XPCReceivedMessage) -> (any Encodable)?, cancellationHandler: (@Sendable (XPCRichError) -> Void)? = nil) -> (XPCListener.IncomingSessionRequest.Decision, XPCSession)Parameters
- incomingMessageHandler:
A closure that receives incoming messages from a client.
- cancellationHandler:
An optional closure that the system invokes when it cancels the session.
Return Value
A tuple that indicates whether the listener accepts or rejects the incoming session, and includes the inactive session.
Discussion
The difference between this method and accept(incomingMessageHandler:cancellationHandler:) is to allow the listener to configure the session, if needed. If you don’t need to perform any session configuration, use accept(incomingMessageHandler:cancellationHandler:) instead.
See Also
Responding to client sessions requests
accept(_:)accept(_:)accept(_:)accept(incomingMessageHandler:cancellationHandler:)accept(incomingMessageHandler:cancellationHandler:)accept(incomingMessageHandler:cancellationHandler:)accept(incomingMessageHandler:cancellationHandler:)accept(incomingMessageHandler:cancellationHandler:)reject(reason:)XPCListener.IncomingSessionRequest.Decision