适用于多达45个设备的Multipeer Connectivity框架 [英] Multipeer Connectivity framework for up to 45 devices

查看:86
本文介绍了适用于多达45个设备的Multipeer Connectivity框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望使用Multipeer Connectivity框架,并希望就如何最好地进行进行交流.

I hope to use the Multipeer Connectivity framework, and would appreciate any voices of experience on how best to proceed.

我需要在教练"设备和最多45个玩家"设备之间建立连接.它们都将位于同一空间,但无法预测wifi的可用性或连接.教练设备需要每秒向所有玩家设备发送一条指令(一个小数据包).每个玩家"都需要每秒将来自蓝牙心率监视器(非常小的数据包)的读数发送回教练.由于每个会话的最多同行人数为8,这些想法中的任何一个都能满足我所需的人数吗?

I need a connection between a "coach" device and up to 45 "player" devices. They will all be in the same space, but no way to predict wifi availability or connection. The coach device needs to send an instruction (a small data packet) to all player devices each second. Each "player" needs to send a reading from a Bluetooth Heartrate monitor (very small data packet) back to the coach each second. Since the maximum peers per session is 8, would any of these ideas work to accommodate the numbers I need?

a)与教练建立连接的前7个播放器设备播发不同的会话类型,并允许另外7个(或将是6个?)播放器加入其中.那些前7个作为中间人,成为其他49个(或42个?)的中间人,将教练的指示传递给教练,然后将收集的读数传回给教练.在指令和心率读数之间的几秒钟的延迟不是优选的,但可以.

a) The first 7 player devices to establish a connection with the coach advertise a different session type and allow 7 (or would this be 6?) more players to join them. Those first 7 act as a middleman to the other 49 (or 42?) by passing on the instruction from the coach and passing back the collected readings to the coach. A few second lag between instruction and heartrate reading is not preferred, but would be OK.

b)教练设备创建并宣告一个会话.连接了7个播放器设备后,教练设备将创建另一个会话,并重复7个以上的会话.重复直到所有播放器设备都连接到教练.这似乎不太可能奏效,但是如果不了解Multipeer Connectivity的魔力,这是我想到的一个选择.

b) The coach device creates and advertises one session. After 7 player devices have connected, the coach device creates another session and repeats for 7 more. Repeat until all player devices are connected to the coach. This seems unlikely to work, but without understanding the magic that is Multipeer Connectivity, it was an option that came to mind.

c)教练与播放器设备1建立会话,该设备以菊花链形连接到设备2....当每个设备接收到指令时,它将自己的读取添加到数据包中并继续发送.最后一个设备将整个数据包返回给教练.我无法预测一轮数据将花费多长时间,而且如果一台设备离开该组也似乎很麻烦.

c) The coach establishes a session with player device one, which connects to device 2... in a daisy chain topography. When each device recieves the instruction, it adds it's own reading to the data packet and sends it on. The last device returns the entire packet to the coach. I can't predict how long it would take for a round of data, and it also seems troublesome if one device leaves the group.

对于在45个左右的设备上使用Multipeer Connection Framework的任何建议或经验,将不胜感激.

Any advice or voices of experience in using Multipeer Connection Framework for 45 or so devices would be appreciated.

推荐答案

最近我一直在考虑类似的问题,如果您不需要'玩家,我想说b)是您的最佳选择以互相交流.

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支持多个会话,因此您可以拥有一个用于会话对象的数组,作为教练"进行广告宣传,并且与每个发现的播放器(如果有容量的话)邀请参加最新的会话,或者创建一个新的会话.

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.

您的播放器对象可以保留对会话和peerID的引用,以用于发送数据,并且可以保留一个对等ID displayNames字典,该字典映射到相应的播放器对象以处理传入数据.

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.

这样,与a)和c)不同,您也不会在给定的玩家"和教练"之间跳动.

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

显然,这里的真正窍门是测试.我本人并不拥有8台以上的设备,我仍然不确定如何测试自己的实现!

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!

修改

我在这里用实际代码回答了类似的问题:用于流数据的最佳选项在iPhone之间

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

这篇关于适用于多达45个设备的Multipeer Connectivity框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆