Down Tips

Way To Learn

Android Tips

How to create an online multiplayer Game server for Android/iOS

DownTips gives you the best solution on How to create an online multiplayer Game server for Android/iOS. 

How massively multiplayer will your game be?

As you noticed, there are two main things to consider:

  1. Information sent to the server
  2. Information sent to the client

There’s only one type of information to send to the server, the user inputs. If you don’t do that, you’ll encounter headaches over headaches when rogue clients try to send fake data to your server (like saying “My tank now has 100,000,000 armor”).

Then what you send to the client is up to you but it’s possible to only send to the client the other player(s)’s input. This is the way to have the absolute minimum and tiniest bandwidth usage possible. That is how games like Blizzard’s Warcraft 3 are doing it. As a bonus, this makes for tiny replay files (because all you need to do to be able to replay a game is the time (and the input) at which each player’s input happened).

The one downside of sending only the other player’s input to the client is that it means all the game’s logic is present on every client. For some games, this may be an issue because people may cheat by reverse engineering your game and finding flaws. This issue can be mitigated with careful, controlled, randomization (where in addition to the input+time you send. input+time+randomness where randomness cannot be guessed by the client in advance.

Another way to do it is to do some logic computation on the server side. Then, you need to send the result of the server computation to the client. Done correctly, this has the benefit of both preventing cheats and making piracy impossible (for example nobody managed to play World of Warcraft in the real economy –that is, on the real Blizzard servers– using a fake license key).

Regarding the phone-turn-based game server: just look at one top-selling turn-based game that is doing it. Take Uniwar for example: works on iPhone and Android. A game server is written in Java “of course”.

The one thing to realize is that a game like the one you plan to write is entirely deterministic: if you can’t easily code a replayer or if you can’t easily reproduce any kind of scenario leading to a logic bug, you’re doing it wrong. (online multiplayer Game server for Android/iOS)

Note that being deterministic doesn’t mean you can’t add what looks like randomness to your players: it’s simply that the randomness shall also be deterministic (for example by simply using a different seed for each game + the time at which player inputs are made as a fake random source).

How to disable the marker click event in Android Studio