0
\$\begingroup\$

What protocol is used to develop real time update games over the internet? From my research here is what I understood:

  1. You cant make one device (phone) as server to host room, you need real server not sure why.
  2. UDP have better performance but the data packet may get lost on the way
  3. TCP HTTP is the easiest way (what I am familiar with) my question here should I use REST and call the server each second from the clients(phones) to update game status or is there a way where the server can update the client?
\$\endgroup\$
1
  • \$\begingroup\$ This is way too broad to be adequately answered. You don't want to use a phone as a host because a phone's internet connection is unreliable. If the host phone dropped offline, the game would most likely end. UDP is not desired for the same reasons. \$\endgroup\$
    – notlesh
    May 21, 2012 at 7:15

3 Answers 3

1
\$\begingroup\$

I can suggest you to read this tutorial : http://gafferongames.com/networking-for-game-programmers/ It explains differences between TCP and UDP and provides an implementation of a UDP-like protocol used in games (in c++).

\$\endgroup\$
1
\$\begingroup\$

First, don't try to reinvent the wheel. Take the idea of TCP or UDP and toss them out of the window. You will likely want to use HTTP with Android's standard URL calls.

As noted before, phones are a bad server. There isn't likely a case where X people are sitting around a table with phones connected to each other. They are likely in various places, doing various things. Phone signal strength varies greatly depending on a number of factors, but it is very likely that a phone will go to sleep or lose connection at some point.

What is the point of these real time updates? Real time on a mobile device is almost always bad. Real time requires almost a constant connection, which usually means a constant flow of network data, which eats up both network bandwidth limits and also will drain the phones battery. I suggest either using push notifications or polling at a reasonable rate (even better if this rate can be set by the user).

Android does support push notifications. These are useful to tell the phone that you have new updates, and then pull the appropriate data. This is where your REST server comes into play. The REST server gives you a central repository so that your game's data won't be lost. I commonly use two different android devices. Applications that sync my data between those devices are far more useful than those that do not.

\$\endgroup\$
0
\$\begingroup\$

It's very difficult to get reliable peer-to-peer communication over the internet. It's much easier to use a central server as a relay among the clients. UDP accepts unreliable communications in exchange for better real-time behavior. It's possible to use two way pipes to exchange data freely, without polling, but also possible to use polled HTTP requests (or other methods) to periodically keep clients up to date. The best choice depends on what the required performance characteristics are, the number of clients, and the amount of data that has to move.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .