A
A
andy3010862016-08-31 22:34:34
Programming
andy301086, 2016-08-31 22:34:34

How to connect two online users in the game?

Hello.
I asked myself a question but could not answer it myself. so I'm asking for advice. How users connect in online games. Suppose a user has logged into the game and is waiting for an opponent (no more than 5 seconds), if he does not wait, then he is given the default value which thread is which. I thought about the queue in which all users who are waiting for the game will be entered and take 2 people from it and throw them the result. Perhaps there are other approaches - thanks in advance

Answer the question

In order to leave comments, you need to log in

3 answer(s)
X
xmoonlight, 2016-08-31
@xmoonlight

Algorithm: card deal, where the "card deck" is a stack of players who want to play with other opponents.
For example, two players in the game: we take the last and the previous connected.
For example, 4 players in the game: last => team1, previous => team2, third (from the end of the stack) => team1, fourth (from the end of the stack) => team2.

I
Ivan, 2016-08-31
@LiguidCool

Well actually google about queues.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question