When using MultipeerSession I can set a limit to the number of peers on each connection using:
Im using peer-to-peer with NWConnection, NWListener, and NWBrowser:
How can I set a limit to the number of users/peers allowed per connection?
Code Block func peerDiscovered(_ peer: MCPeerID) -> Bool { if multipeerSession.connectedPeers.count > 4 { // Do not accept more than four users in the experience. return false } }
Im using peer-to-peer with NWConnection, NWListener, and NWBrowser:
Code Block let params = NWParameters() params.includePeerToPeer = true
How can I set a limit to the number of users/peers allowed per connection?
Code Block self.connection?.receiveMessage { (data, context, isComplete, error) in if (isComplete) { if let data = data, !data.isEmpty { // do something with data } } }