send(_:completionHandler:)
Sends a WebSocket message, receiving the result in a completion handler.
Declaration
@preconcurrency func send(_ message: URLSessionWebSocketTask.Message, completionHandler: @escaping @Sendable ((any Error)?) -> Void)Parameters
- message:
The WebSocket message to send to the other endpoint.
- completionHandler:
A closure that receives an Nserror that indicates an error encountered while sending, or nil if no error occurred.
Discussion
If an error occurs while sending the message, any outstanding work also fails.