Could someone guide me a little on how to play online from my application?
I've been looking for things but it's not possible for me to find something that poses something similar or something that comes a little closer to what I want to do.
Basically it is a button that I want it to detect if someone is connected and to search among all the available users at that moment and those who are not in a game, and from there to be able to do everything related to the games.
I have some points that above all are the ones that I have the most doubt about...
-How do I detect if a user is active in my application? -How to detect if the user has been disconnected in my application? -How do you get a button to search for an online game, with the users that are available? -How to contemplate that if a player is already in a game so that he does not appear in several games? (Although it is, I think it is easier, if I can do all the previous steps)
If someone can guide me a little, their help would be very useful... (My final goal is also to be able to upload the created game to the Play Store), although I don't know if that will be useful information to help me
Thanks in advance!
in your db you could add a field: connected giving a 1 if it is connected and a 0 if not, the same, in the same field if the user is playing you put a 2 therefore if the connected user == 1 it is possible to search for a game another way.... you know offline or playing. make a query to the db and know all the ones that have status connected==1, I know in my case I would do it through ajax but they all have their techniques, for example I don't know how to work with angular 5 there must be a way, also in react there is another way... therefore every time a user searches for a game you would have to do an asynchronous function through ajax to make a query in the database and bring back the result of who is connected and who is not.
In my case the ajax json.html is already the complete list of all the users with the query already made that brings a table with those connected = 1 and you make an append to some div like this:
AJAX