Multipeer Connectivity framework for up to 45 devices

放肆的年华 提交于 2019-12-04 02:54:55
ChrisH

I've been pondering something similar lately, and I'd say in your case b) would be your best option if you don't need the 'players' to communicate with each other.

Multipeer Connectivity supports multiple sessions so you could have an array for session objects, advertise as the 'coach' and with each discovered player either invite to the latest session if it has capacity or create a new one.

Your player object can keep a reference to the session and peerID for the purposes of sending data, and maybe keep a dictionary of peerID displayNames mapped to the corresponding player object to handle incoming data.

This way you also have no hops between a given 'player' and the 'coach', unlike with a) and c).

Obviously the real trick here is testing. I myself don't own 8+ devices and I'm still not sure how I'm going to test my own implementation!

Edit

I answered a similar question with actual code here: Best option for streaming data between iPhones

I Know that it is an old question. I had the same problem mounts ago (and have asked a similar question without clear answer).

Things that I have tested and problems faced:

  1. The "normal way" -- one session.

    • Problem: Maximum 8 devices.
  2. Array of sessions putting 6 devices on each session (to avoid the maximum 8)

    • Problem: To much overheating, memory and cpu consumption. When several devices from several session get disconnected at a time the reconection can take to much time to be aceptable.
  3. This is the most complicated way.

    Steps:

    1. We create the session and allow a maximum of 4 - 5 clients.
    2. Every time a client is connected he create a group with the same conditions.
    3. When We reach the maximum client count (4 - 5 depending on your implementation ) we stop advertising.
    4. New clients will be connected between each other like cells. The trick is to have some method to decide witch sessions the new client needs to connect to ordered by priority and create a method to resent traffic to the client session to the "server replicator" one.

The only problem with the last method is that it is the most complicated and you need some maths a pencil and a peace of paper to decide how you will interconect your clients and resend your traffic.

Instead of MultiPeer Connectivity framework, You can go with this https://github.com/jdiehl/async-network#request-based-networking

the default is 8, it's not the maximum,

you question scared me, as I will need more than 8 too!!

it must of been poorly written looks corrected below.

maximumNumberOfPeers The maximum number of peers allowed in a session, including the local peer. @property(assign, nonatomic) NSUInteger maximumNumberOfPeers Discussion The largest allowable value (and the default) is 8.

https://developer.apple.com/library/ios/documentation/MultipeerConnectivity/Reference/MultipeerConnectivityFramework/MultipeerConnectivityFramework.pdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!