Multipeer Connectivity - Preventing unwanted connections

Hi,

I'm trying to use the Multipeer Connectivity framework in my latest app to create a mesh network between many devices (20+). I only plan to have each device connected to at most 4 other devices to avoid the limitations of the MC framework.

However, when testing it out I found that when connecting multiple peers together, the MCSessions seemed to sync up. I.e. when I had device 1 connect to device 2, and then device 1 connect to device 3, automatically device 2 would connect to device 3.

Is there any way to prevent these automatic connections from forming between devices?

I am using swift 5 / iOS 14

Thanks

Replies

No, this is simply the way that Multipeeer Connectivity works.

If you want more direct control over the network topology, use a lower-level API like Network framework.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Thanks Quinn.

    As a follow-up question, would there be any significant issues/disadvantages to using multiple MCSession objects for each pair of connections to bypass the automatic connections from forming?

Add a Comment

would there be any significant issues/disadvantages to using multiple MCSession objects for each pair of connections to bypass the automatic connections from forming?

I’ve seen folks do that, with varying degrees of success.

At this point you need to ask yourself “What is Multipeer Connectivity actually buying me?” I suspect that the answer is “Very little.”, and thus it’d be better to move to a lower-level API.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"