Instance Method

URLSession:webSocketTask:didCloseWithCode:reason:

Tells the delegate that the WebSocket task received a close frame from the server endpoint, optionally including a close code and reason from the server.

Declaration

- (void)URLSession:(NSURLSession *)session webSocketTask:(NSURLSessionWebSocketTask *)webSocketTask didCloseWithCode:(NSURLSessionWebSocketCloseCode)closeCode reason:(NSData *)reason;

Parameters

session

The session of the WebSocket task that closed.

webSocketTask

The WebSocket task that closed.

closeCode

The close code provided by the server. If the close frame didn’t include a close code, this value is nil.

reason

The close reason provided by the server. If the close frame didn’t include a reason, this value is nil.

See Also

Handling WebSocket Lifecycle Events

- URLSession:webSocketTask:didOpenWithProtocol:

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