当前位置: 动力学知识库 > 问答 > 编程问答 >

ios - Connecting more than 2 devices together using Multipeer Connectivity

问题描述:

I am having a problem with a chatting app i am writing in Swift using Multipeer Connectivity. Getting 2 devices to share their sessions together seems to work no problem, however when I connect a 3rd, the application starts to do weird things.

For example: you have 3 devices; Device A, Device B & Device C.

I connect Device A to Device B, all is fine, both can talk to each other & share their profile (upon the 2 devices connecting to each other, they share the profile picture with each other).

I then connect Device A to Device C. They connect and more often than not will share profiles with each other. But then Multipeer Connectivity seems to want to share Device C's session to Device B's without the user asking, attempts to share profiles, then one of the devices (usually Device C in this example) will crash & close the app.

When Multipeer Connectivity runs the method, it runs to connect 2 devices sessions together. It appears to want to gather all connected user sessions from each device & attempt to connect either device to all connected users known to the opposite. Could anybody explain to me why Multipeer Connectivity would do this & if theres anyway to stop it doing this?

I do realise the MPC uses Mesh Networking to allow devices to communicate via other devices using a daisy-chained-style connection, but I don't see why they are sharing each others sessions. Surely it should only share sessions with the requested devices rather than everyone each are connected to?

分享给朋友:
您可能感兴趣的文章:
随机阅读: