Contents

sendIdempotent(_:metadata:)

Send an idempotent text frame on a WebSocket connection.

Declaration

func sendIdempotent(_ content: String, @ProtocolMetadataBuilder metadata builder: () -> [NWProtocolMetadata] = {[]})

Parameters

  • content:

    A string to send.

  • builder:

    A builder for specifying metadata about the content to send.

Discussion

Idempotent content is allowed to be sent before the connection is ready, and may be replayed across parallel connection attempts. This content can be sent as part of fast-open protocols, which allows the data to be sent out sooner than if it were required to wait for connection establishment.

Content that needs to be sensitive to sending backpressure should not be considered idempotent.

This may be called before the connection is ready, in which case the send will be enqueued until the connection is ready to send.