Realtime multiplayer game over mobile network?
I just discovered that my phone is behind a symmetric udp firewall, which simply means that udp traffic is not possible. My 3g provider is t-mobile which is one of the biggest in my country. I suspect that many more mobile 3g providers have udp limitations in place.
I'm planning on 开发者_JAVA百科developing a realtime game. udb seemed to be the right solution for quick movement, but i can't use udp because then i lose flexibility (play anywhere, many places with no wifi) and a big audience (3g providers which block udp).
Mobile networks like umts and 3g have high latency, so tcp (with resending lost packets, and queuing) is not ideal solution.
Is there a alternative? Or should drop the idea of a realtime game over 3g?
It is very hard to achieve real time over the network with satisfying latency for your game logic (especially if you are making a game like first person shooter, you can read about overcoming some latency issues here: networked physics).
When talking about mobile network, well, it gets even harder: Of course you can make your life easier and cover only WIFI connection, BUT you will lose all the users that want to play over 3G when no FREE WIFI connection is available (or they simply stuck with 3G connection because they don't know how to change to WIFI). If you chose to cover 3G as well welcome to the operators hell: no UDP, no sockets, no none-standard ports, no long timeouts, and hello disconnections, hello strange headers and hello weird proxies, now multiply it by the number of different operators over the world and Voila' you cover all their issues.
I am not trying to scare you, just remember these things during your implementation:
1. No sockets or usage of none-standard ports - sockets are not allowed by operators from obvious reasons, they don't want you to take their resources because during that time they could serve some other paying customer ;) If your game logic allows it, try implementing the protocol without sockets.
2. Test your game with a couple of friends over the seas or use crowd testing services that can do it for you. You can calibrate the latency through your own protocols.
3. Distributing your servers will greatly help with the latency issue.
4. Make sure you are not sending a lot of data over the network, be smart, be gentle with the device's battery.
5. Compress your data!
For full disclosure: I am working at Skiller and we provide multiplayer SDK for Android developers (among others) with free tools like social layer, user management, revenue generation etc... We saw a lot of issues with multiplayer over 3G and we compensate it with the algorithms we wrote on the client and server side to make developer's lives easier. If you want to try us out: www.skiller-games.com
There are some cloud based real-time messaging services designed to adaptively work over many different mobile platforms. In gaming you often want publish / subscribe so one you might look at is http://pubnub.com They take care of your cloud infrastructure with 14 data centres providing low latency. Their APIs are ideal for gaming with security and presence APIs designed for this. They have a new object data sync API in beta that can cut down on coding.
A key reason I like them is because they have been in the business for many years and so their APIs have been tested on most worldwide 3G and corporate networks.
Others you might look at include pusher.com and realtime.co and Google's new https://cloud.google.com/pubsub/ service.
精彩评论