简体   繁体   English

Android蓝牙游戏连接

[英]Android Bluetooth Game Connection

I recently made a game for Android and want to add a multiplay feature to it, to avoid server cost i plan to use bluetooth to connect up to 8 devices together and share small amounts of data on their progress within the game (score and if they are still connected). 我最近为Android开发了一款游戏,并希望向其中添加多人游戏功能,以避免服务器成本,我计划使用蓝牙将多达8台设备连接在一起,并在游戏中分享有关其进度的少量数据(分数以及是否仍然连接)。 Spent a while looking at web tutorials and the Android API and thats just made me more confused. 花了一些时间看网络教程和Android API,这让我更加困惑。 Anybody have any advice on what to do or any good tutorials on this issue. 任何人都该如何做有任何建议或有关此问题的任何很好的教程。

I believe bluetooth is more of a p2p type network. 我相信蓝牙更像是p2p类型的网络。

I would suggest using wifi or wifi direct, maybe even have one phone be a hot spot they all connect to. 我建议使用wifi或wifi直连,甚至连一部手机都可以成为他们都连接的热点。

Or you can do something like the networking standard ospf does and instead of flooding the entire network with updates send an update to one designated device which sends it out to all others. 或者,您可以执行ospf网络标准那样的操作,而不是用更新淹没整个网络,而是将更新发送到一个指定的设备,然后将其发送给所有其他设备。

According to an answer here: Android Bluetooth API connect to multiple devices 根据这里的答案: Android蓝牙API连接到多个设备

You can certainly connect to multiple devices, but by the other answers I would heavily suggest against it given the other technology we have these days. 您当然可以连接到多个设备,但是考虑到我们如今拥有的其他技术,对于其他答案,我会强烈建议不要这样做。 Mist devices out there wont be able to handle 7 different devices, let along have a good enough battery to commit to such processes. 那里的薄雾设备将无法处理7种不同的设备,顺带一个足够好的电池可用于此类过程。

Given at least 1 of your devices are modern I would use wifi... 鉴于您至少有1台设备是现代设备,因此我会使用wifi ...

Just to let you know of the existence of other possibilities, there's WiFi Direct , which allows the connection of Android devices via WiFi and without an access point. 为了让您知道其他可能性的存在, WiFi Direct可以通过WiFi在没有访问点的情况下连接Android设备。 Quoting the intro: 引言简介:

Wi-Fi Direct allows Android 4.0 (API level 14) or later devices with the appropriate hardware to connect directly to each other via Wi-Fi without an intermediate access point. Wi-Fi Direct允许具有适当硬件的Android 4.0(API级别14)或更高版本的设备通过Wi-Fi直接彼此连接,而无需中间访问点。 Using these APIs, you can discover and connect to other devices when each device supports Wi-Fi Direct, then communicate over a speedy connection across distances much longer than a Bluetooth connection. 使用这些API,您可以在每台设备都支持Wi-Fi Direct时发现并连接到其他设备,然后通过比蓝牙连接更长的距离进行快速连接进行通信。 This is useful for applications that share data among users, such as a multiplayer game or a photo sharing application. 这对于在用户之间共享数据的应用程序(例如多人游戏或照片共享应用程序)很有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM