简体   繁体   English

Android手机之间的位置交换

[英]Location exchange between Android phones

I'm seeking more an advice on where to go next, rather than how to do it. 我正在寻求更多有关下一步工作的建议,而不是如何做。

I'm developing an augmented reality Android game as a student project, and I've stumbled upon a problem. 我正在开发一个增强现实的Android游戏,作为一个学生项目,但我偶然发现了一个问题。 Four phones have to know each other's position and show it on a map with time steps (it should not be really realtime, for the sake of the game). 四部手机必须知道彼此的位置,并在地图上显示时间步长(就游戏而言,它不应是实时的)。 Besides that, the players should be notified when one of the phones/players gets to some location, or does something. 除此之外,当电话/播放器之一到达某个位置或执行某项操作时,应通知播放器。

I wanted to do it with a PHP service, where each phone would check in a couple of seconds for the positions of the rest (all by JSON), send it's position and that's it. 我想用一个PHP服务来做到这一点,其中每部电话都会在几秒钟内检查其余位置(全部通过JSON),然后发送位置信息。 Quite simple, but I'm afraid that there will be a lot of desynchronisation and unconsitent data as the game progresses. 很简单,但是随着游戏的进行,恐怕会出现许多不同步和不一致的数据。 Since the phones don't start at the same second as everyone signs in. Also, I'm not sure how to do the events this way (for example, one of the players can cloak and his position should not be updated anymore in the next x seconds), or get to a location, or what items are still on the map (players can "pick up" items). 由于电话的启动时间与所有人登录的时间都不相同。此外,我不确定如何以这种方式进行活动(例如,其中一名玩家可以隐身,并且不应再更新他的位置了)接下来的x秒),或者到达某个位置,或者地图上还有哪些物品(玩家可以“拾取”物品)。 Someone will know earlier than the others. 有人会比其他人更早知道。

This really calls for a push-like solution, but I'm not really familiar with C2DM, and it seems to me that using it is a real overhead in development, and I need a C#/Java or similar server as PHP certanly can't push to the cloud (or can it?). 这确实需要一个类似push的解决方案,但我对C2DM并不真正熟悉,在我看来,使用它在开发中确实是一项真正的开销,并且我需要C#/ Java或类似PHP的服务器。不要推向云端(或者可以吗?)。 I know C# and Java, but it takes more time as I need to solve threading and so on. 我知道C#和Java,但是需要更多时间来解决线程等问题。 Can C2DM even be used for this? C2DM甚至可以用于此吗?

Basically, I'm seeking thoughts of more experienced developers, what is the best solution here for sync? 基本上,我正在寻求经验丰富的开发人员的想法,这里同步的最佳解决方案是什么? Is there any way to remedy the problems with PHP and periodic checking the server or should I continue with the cloud service and a more complicated server? 有什么方法可以纠正PHP的问题并定期检查服务器,还是应该继续使用云服务和更复杂的服务器?

Sorry for the long explanation :) . 抱歉,冗长的解释:)。

Sorry that this isn't simpler but I've encountered pretty much the exact same problem in my own app and there is no way to avoid this, you need; 抱歉,这并不简单,但是我在自己的应用程序中遇到了几乎完全相同的问题,您无法避免这种情况。

  1. a server with a REST API to manage and distribute data 具有REST API的服务器来管理和分发数据
  2. a way to set up friends / groups 建立朋友/团体的方法
  3. a way to push data 一种推送数据的方法

Google Cloud Messaging really isn't that much trouble. Google Cloud Messaging确实没有那么多麻烦。

Check out the Google IO 2012 code, they've made use of it there with not much code. 查看Google IO 2012代码,他们在那里使用它的代码很少。

http://code.google.com/p/iosched/source/browse/ http://code.google.com/p/iosched/source/browse/

What you really need to build is a rest api with quite a few functions for being able to identify devices and set up these groups of friends. 您真正需要构建的是一个rest api,它具有很多功能,能够识别设备并设置这些朋友组。 I would suggest using Facebook integration for establishing a friend network. 我建议使用Facebook集成来建立朋友网络。

https://developers.facebook.com/ https://developers.facebook.com/

And there are infinite ways to set up the REST API, but the fastest I've seen was released this year at google IO and thats Google AppEngine EndPoints. 设置REST API的方法有很多,但我见过的最快的方法是今年在Google IO和Google AppEngine EndPoints上发布的。

http://devthots.blogspot.com/2012/07/building-awesome-android-apps-with.html http://devthots.blogspot.com/2012/07/building-awesome-android-apps-with.html

尝试Comet ,这全都与http请求有关

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

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