Instance Method

webSocketTaskWithURL:protocols:

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

Declaration

- (NSURLSessionWebSocketTask *)webSocketTaskWithURL:(NSURL *)url protocols:(NSArray<NSString *> *)protocols;

Parameters

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.

See Also

Adding WebSocket Tasks to a Session

- webSocketTaskWithURL:

Creates a WebSocket task for the provided URL.

- webSocketTaskWithRequest:

Creates a WebSocket task for the provided URL request.

NSURLSessionWebSocketTask

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

NSURLSessionWebSocketDelegate

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