Contents

webSocketTask(with:protocols:)

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

Declaration

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

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