Contents

close(code:reason:metadata:)

Send a WebSocket close frame on a connection.

Declaration

func close(code: NWProtocolWebSocket.CloseCode = .protocolCode(.normalClosure), reason: String? = nil, @ProtocolMetadataBuilder metadata builder: () -> [NWProtocolMetadata] = {[]}) async throws

Parameters

  • code:

    Optional close code. Defaults to normal closure.

  • reason:

    Optional reason string containing details about the closure.

  • builder:

    A builder for specifying metadata about the content to send.

Discussion

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