Sends a WebSocket message, receiving the result in a completion handler.
SDKs
- iOS 7.0+
- macOS 10.9+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
- Xcode 11.0+
Framework
- Foundation
Declaration
func send(_ message: URLSession Web Socket Task.Message, completionHandler: @escaping (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.