Instance Method

webSocketTask(with:)

Creates a WebSocket task for the provided URL.

Declaration

func webSocketTask(with url: URL) -> URLSessionWebSocketTask

Parameters

url

The WebSocket URL with which to connect.

Discussion

The provided URL must have a ws or wss scheme.

See Also

Adding WebSocket Tasks to a Session

func webSocketTask(with: URLRequest) -> URLSessionWebSocketTask

Creates a WebSocket task for the provided URL request.

func webSocketTask(with: URL, protocols: [String]) -> URLSessionWebSocketTask

Creates a WebSocket task given a URL and an array of protocols.

class URLSessionWebSocketTask

A URL session task that communicates over the WebSockets protocol standard.

protocol URLSessionWebSocketDelegate

A protocol that defines methods that URL session instances call on their delegates to handle task-level events specific to WebSocket tasks.