Contents

urlSession(_:webSocketTask:didOpenWithProtocol:)

Tells the delegate that the WebSocket task successfully negotiated the handshake with the endpoint, indicating the negotiated protocol.

Declaration

optional func urlSession(_ session: URLSession, webSocketTask: URLSessionWebSocketTask, didOpenWithProtocol protocol: String?)

Parameters

  • session:

    The session of the WebSocket task that opened.

  • webSocketTask:

    The WebSocket task that opened.

  • protocol:

    The protocol picked during the handshake phase. This parameter is nil if the server did not pick a protocol, or if the client did not advertise protocols when creating the task.

Discussion

If the handshake fails, the task doesn’t call this delegate method.

See Also

Handling WebSocket lifecycle events