One Logo Pool Ball
Network · IOS API REFERENCE

NWConnection.ContentContext

class · iOS 12.0+ · SDK 27.1

class ContentContext

Content Context controls options for how data is sent, and access for metadata to send or receive. All properties of Content Context are valid for sending. For received Content Context, only the protocolMetadata values will be set.

Members (11)

get · iOS 12.0+

antecedent

TypeScript
get antecedent(): (NWConnection_ContentContext) | null
Swift declaration
final let antecedent: NWConnection.ContentContext?

Any content marked as an antecedent must be sent prior to this content being sent. Defaults to nil. Used only when sending.

init · iOS 12.0+

init

TypeScript
static init(identifier: string, expiration?: number, priority?: number, isFinal?: boolean, antecedent?: (NWConnection_ContentContext) | null, metadata?: (Array<NWProtocolMetadata>) | null): NWConnection_ContentContext
Swift declaration
init(identifier: String, expiration: UInt64 = 0, priority: Double = 0.5, isFinal: Bool = false, antecedent: NWConnection.ContentContext? = nil, metadata: [NWProtocolMetadata]? = [])

Create a context for sending, that optionally can set expiration (default 0), priority (default 0.5), antecedent (default nil), and protocol metadata (default []]).

get · iOS 12.0+

identifier

TypeScript
get identifier(): string
Swift declaration
final let identifier: String

A string description of the content, used for logging and debugging.

get · iOS 12.0+

finalMessage

TypeScript
static get finalMessage(): NWConnection_ContentContext
Swift declaration
static let finalMessage: NWConnection.ContentContext

Use the final message context to indicate that no more sends are expected once this context is complete. Like .defaultMessage, all properties are default. Marking a send as complete when using this context will close the sending side of the underlying connection. This is the equivalent of sending a FIN on a TCP stream. This context does not support overriding any properties.

get · iOS 12.0+

defaultStream

TypeScript
static get defaultStream(): NWConnection_ContentContext
Swift declaration
static let defaultStream: NWConnection.ContentContext

Use the default stream context to indicate that this sending context is the one that represents the entire connection. All context properties are default. This context behaves in the same way as .finalMessage, such that marking the context complete by sending isComplete will close the sending side of the underlying connection (a FIN for a TCP stream). Note that this context is a convenience for sending a single, final context. If the protocol used by the connection is a stream (such as TCP), the caller may still use .defaultMessage, .finalMessage, or a custom context with priorities and metadata to set properties of a particular chunk of stream data relative to other data on the stream. This context does not support overriding any properties.

get · iOS 12.0+

defaultMessage

TypeScript
static get defaultMessage(): NWConnection_ContentContext
Swift declaration
static let defaultMessage: NWConnection.ContentContext

Use the default message context to send content with all default properties: default priority, no expiration, and not the final message. Marking this context as complete with a send indicates that the message content is now complete and any other messages that were blocked may be scheduled, but will not close the underlying connection. Use this context for any lightweight sends of datagrams or messages on top of a stream that do not require special properties. This context does not support overriding any properties.

method · iOS 12.0+

protocolMetadata

TypeScript
protocolMetadataDefinition(definition: NWProtocolDefinition): (NWProtocolMetadata) | null
Swift declaration
func protocolMetadata(definition: NWProtocolDefinition) -> NWProtocolMetadata?

Access the metadata for a specific protocol from a context. The metadata may be nil.

get · iOS 12.0+

protocolMetadata

TypeScript
get protocolMetadata(): Array<NWProtocolMetadata>
Swift declaration
var protocolMetadata: [NWProtocolMetadata] { get }

An array of protocol metadata to send (to inform the protocols of per-data options) or receive (to receive per-data options or statistics).

get · iOS 12.0+

relativePriority

TypeScript
get relativePriority(): number
Swift declaration
final let relativePriority: Double

A numeric value between 0.0 and 1.0 to specify priority of this data/message. Defaults to 0.5. Used only when sending.

get · iOS 12.0+

expirationMilliseconds

TypeScript
get expirationMilliseconds(): number
Swift declaration
final let expirationMilliseconds: UInt64

An expiration in milliseconds after scheduling a send, after which the content may be dropped. Defaults to 0, which implies no expiration. Used only when sending.

get · iOS 12.0+

isFinal

TypeScript
get isFinal(): boolean
Swift declaration
final let isFinal: Bool

A boolean indicating if this context is the final context in a given direction on this connection. Defaults to false.

Skipped declarations

No declarations were skipped in this snapshot.

All Network types →