Instance Method


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


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



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.


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

See Also

Sending and Receiving Data

func send(URLSessionWebSocketTask.Message, completionHandler: (Error?) -> Void)

Sends a WebSocket message, receiving the result in a completion handler.

enum URLSessionWebSocketTask.Message

An enumeration of the types of messages sent and received.

var maximumMessageSize: Int

The maximum number of bytes to buffer before the receive call fails with an error.