Instance Method

send(_:toPeers:with:)

Transmits a collection of bytes to a list of connected peers.

Declaration

func send(_ data: Data!, toPeers peers: [Any]!, with mode: GKSendDataMode) throws

Parameters

data

The bytes to be sent.

peers

An array of NSString objects identifying the peers that should receive the data.

mode

The mechanism used to send the data.

error

If the data could not be queued, an NSError object describing the error.

Return Value

true if the data was successfully queued for transmission; false if the session object was unable to queue the data.

Discussion

The session queues the data and transmits it in the order it was queued. Data transmitted unreliably may be received out of order by the other peers.

See Also

Working with Connected Peers

func setDataReceiveHandler(Any!, withContext: UnsafeMutableRawPointer!)

Sets the object that handles data received from other peers connected to the session.

Deprecated
func sendData(toAllPeers: Data!, with: GKSendDataMode)

Transmits a collection of bytes to all connected peers.

Deprecated
var disconnectTimeout: TimeInterval

A time interval that expresses how long the session waits before it disconnects a nonresponsive peer.

Deprecated
func disconnectFromAllPeers()

Disconnects the session from all connected peers.

Deprecated
func disconnectPeer(fromAllPeers: String!)

Disconnects a connected peer from all peers connected to the session.

Deprecated

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software