简体   繁体   中英

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. 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. 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). 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?). I know C# and Java, but it takes more time as I need to solve threading and so on. Can C2DM even be used for this?

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?

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
  2. a way to set up friends / groups
  3. a way to push data

Google Cloud Messaging really isn't that much trouble.

Check out the Google IO 2012 code, they've made use of it there with not much code.

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. I would suggest using Facebook integration for establishing a friend network.

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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