Question

I started to make multiplayer game but as I have no expirience I tried it different ways but something doesn't feel right to me. So, I really need an advice about which platforms/tools/languages/techniches I should use best. I must say that I don't believe in things such as: Photon, AppWrap, Skiller, Gamooga and others. I dont believe they will scale great and it won't be too pricey, or they are too big (I don't mean size, I mean how much things they has that I don't need) for my needs.

First, I'll describe simplified game session proccess.

  1. Three players starting the game session
  2. Each player receives a question and should answer within 10 seconds.
  3. When player answered he should be able to see any answers that were given already by any other players (if any) and he should be able to see any answer given as soon as it was given. Basically, any answers should be received by other clients in realtime but only after we answered (to avoid cheating). If time is out then any who doesn't answered will receive no score and next question goes.
  4. Deciding winner and goes to the next question. Finish the game session after N rounds.

Second, I'll explain few requirements that I taken into consideration.

  • Game should be run on iOS/Android/Web. This leaves me no choice but to make it based on HTTP.
  • I looked for Google Cloud Endpoints about which I was really enjoyed. It has iOS/Android/JS SDKs, Google Cloud Platform has Google BigQuery, and many other great things. But because I need realtime answer delivery I don't know if that suitable (there is Channel API but no client SDK for iOS, and people saying its not that good).
  • Then I looked for Node.js and long polling (AFNetworking on client side) but it is so hard to manage. I need to serve game state updates to clients (and I need to send deltas). That way I need to track all changes individually for each player. And when player connects I should check if there any changes already; if it is then send right away; if it isn't then listen for 'change' event and then send. In the end code looks so awkward and hard to understand and I don't know how to make it right. There is socket.io which should make things better on the server side but again no iOS SDK for client.

I don't know where to go from here. Any help would be very appreciated.

Was it helpful?

Solution

Turn based architectures are actually not too complicated as lag is really not a huge concern, and data is not being sent constantly.

I would create two web services, one for matchmaking and another to handle the actual game.

The matchmaking would simply queue up players, when there were enough for a match, the service would pick a group of players and assign them a sessionID and pass the players to the game service.

For the game service, it is important to differentiate what can be handled on the client and the service.

The game service would store all game information for each sessionID including clients. This would allow a single service to manage hundreds of games at once with ease. When a player answered a question it would send that in a request to the server with the sessionID. The server would iterate over the clients in the session and send the information to them.

The client could handle hiding questions until the user has answered. (You could even encrypt the other question information if you were concerned about hacking).

The server would also track the timer for the session, when the timer expired it would send a response to all the clients, as well as ignore any later answers. A round integer could be stored in the session, and wrapped in communication with sessionID so as to differentiate answers to past questions. You could have a timer for prediction on the client, but the server needs to be the authority over the timer to avoid cheating.

OTHER TIPS

Use secure ssl https protocols using your own auth tokens to keep the cheaters out.

The client would need to keep track of time span for each player not the actual time. The individual times spans are sent to the server after the round ends on each client.

Think of it like this. There are 3 clients, all polling a server as when they start the round. Because the three could have varying network speeds you don't know who will actually start first. So when each client finally receives the green light then the timer starts for that device, on that device at that time it is received on that client device. You wait until all 3 report back to the server with their time spans to determine who won the round.

There as some topics of concern out of the logic of just the game. Here are some examples. User Identity and Authorizing. (Game Center) Game Data Persistence and Storage. (Cloud Database like AWS DynamoDB) Game Match Queuing. (AWS SQS) Don't attempt this with a database using pessimistic concurrency. Notifications of Match Players are ready for sleeping clients. (AWS SNS to APNS to Endpoint(this mobile device)) Polling or Notification for Next Move. (AWS SQS or SNS) I wouldn't poll the Database. Those services are just example recommendations. I don't work for Amazon, they are the easiest to get up and running but there maybe better services out there.

Basically what I am getting at you are going to want more than a traditional MySQL database on some basic hosting site. Some of these cloud services have become very affordable as compared to creating all the infrastructure yourself on dedicated servers. The are exponentially more scalable also. You could do all that listed above to start out for under $15 a month using cloud services. The best thing is if your idea takes off you simply bump up the thresholds on those with a flick of a switch from an admin portal. That would be a good problem to have.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top