D
D
Delfuego2015-01-17 00:49:43
Mobile development
Delfuego, 2015-01-17 00:49:43

How to make client-server interaction in PvP in a mobile game?

Hello! I am making a game for smartphones on Unity, you may have read my articles from Habr (Stories about enchanting failures in game development, part 1 and 2). I got to the PvP part and the question arose: what architecture of client-server interaction should be done?
How PvP works:
1. The player logs in via vk (so far only through it, because I plan to soft-lunch for Russia and the CIS)
2. The player's list of friends is loaded. Those who have the game can immediately send an invitation to PvP, and those who do not have it can send an offer to install the game on the
wall
4. Game sessions take place asynchronously, the player interacts only with opponents, the type and frequency of which I set in advance. The player who scores the most points in such a PvE battle wins.
What I don't understand the most is: what information should be read from another player in order to send him an invitation? As I understand it, you need to get information about player 2 from the api contact in order to send him an invite, right? What is this information?
I would be grateful for any useful information and links, including about pitfalls. I am also looking for this information, but maybe something can escape me.
I plan to make the server on Apache + Mysql + Codeigniter (I chose this framework because the documentation in it seemed to me more understandable than in Yii). Prior to this, I had never been involved in server development before.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan Luxurious, 2015-02-13
@oshikuru

When you connect any player to the server, mark on the server that he is online. Then, if necessary, look for online players in your list and send him an invitation.
Simplified connection:
1) Connect the player to the server.
2) Add its id to the list online.
3) Set him the status "out of battle"
Simplified search for an opponent:
1) Look in the list online, find the first one who has the status "out of battle"
2) Create a room for a fight, put both participants in it
3) Set the status "waiting for battle" for both participants ".
4) Send an invitation to both participants.
5) After the consent of both participants, set the status "in battle" to both and start the battle.
The implementation details and the choice of technologies for connecting to the server, storing the session, questions about updating the session information and its relevance (is the player still online) - I leave it outside the scope of this answer. Probably vk-api has some way to find out if the user is online or not. But most likely you will have to implement it yourself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question