webSocketTask(with:protocols:)
Creates a WebSocket task given a URL and an array of protocols.
Declaration
func webSocketTask(with url: URL, protocols: [String]) -> URLSessionWebSocketTaskParameters
- url:
The WebSocket URL with which to connect.
- protocols:
An array of protocols to negotiate with the server.
Discussion
During the WebSocket handshake, the task uses the provided protocols to negotiate a preferred protocol with the server.