Contents

receive(completionHandler:)

Reads a WebSocket message once all the frames of the message are available.

Declaration

@preconcurrency func receive(completionHandler: @escaping  @Sendable (Result<URLSessionWebSocketTask.Message, any Error>) -> Void)

Parameters

  • completionHandler:

    A closure that receives two parameters: the WebSocket message, and an Nserror that indicates an error encountered while receiving the message. The error is nil if no error occurred.

Discussion

If the task reaches the maximumMessageSize while buffering the frames, this call fails with an error.

See Also

Sending and receiving data