Instance Method

acceptConnection(fromPeer:)

Called by the delegate to accept a connection request received from a remote peer.

Declaration

func acceptConnection(fromPeer peerID: String!) throws

Parameters

peerID

The string identifying the peer that initiated the connection to the session.

error

If an error occurred when connecting the peer, upon return contains an NSError object that explains the problem.

Return Value

true if a connection was established to the remote peer; false if an error occurred.

Discussion

When your session acts as a server, client peers can discover your session and attempt to connect to it. When a client attempts to connect to the session, the delegate’s session(_:didReceiveConnectionRequestFromPeer:) method is called to decide whether the peer should be connected. Your application calls this method to accept the request, or denyConnection(fromPeer:) to reject it.

See Also

Receiving Connections from a Remote Peer

func denyConnection(fromPeer: String!)

Called by the delegate to reject a connection request received from a remote peer.

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