K
K
kazmiruk2013-04-23 17:05:16
Game development
kazmiruk, 2013-04-23 17:05:16

How to organize a dynamic list of games available for connection?

There is a game, the essence of which is to create a battle by one player, to which other players can join (a given number).
Technologies used:
web sockets (server using gevent);
web server (used for ajax requests for purchasing goods, working with inventory, etc., as well as for generating a page with the game).
Now there is a task to make a list of games available for connection, which changes according to the following events:
- the player created the game;
- another player has joined the game (the remaining number of places in this game should change or the game should leave the list if it's already the maximum);
- the player changed his mind about connecting to the game (change in the number of remaining places);
- the player canceled the creation of the game (removal from the list).
That is, in theory, with a large number of players, this list will change very often, which, again in theory, can create a high load.
Now I'm considering two options:
- requesting a list of games from the database / cache via ajax every 20 (or 10, 30, 50) seconds. Of the pluses - reducing the load (the first user requests from the database, the data is cached for 20 seconds and the rest is taken from the cache), of the minuses - the player does not know in time that the game he is connecting to is no longer available (can be reduced to 5 seconds or 10, but How effective will it be?
- each list change event is broadcast via web sockets to all players connected to the server. Pluses - instant change of the list, minuses - changes, as I said, will occur quite often and each change will have to be sent to everyone, which can lead to an avalanche of requests.
How would you organize such functionality?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri Shikanov, 2013-04-23
@dizballanze

The second option, but not web sockets, but something like socket.io , because web sockets do not work everywhere.
To solve the problem with a wave of requests, you can update the rooms page by page. Those. obviously, all rooms will not need to be shown on the screen at the same time (they simply won’t fit), respectively, the user will be subscribed only to changes in those rooms that are currently shown on the screen.

S
SiDChik, 2013-04-24
@SiDChik

If it is calculated that after each update the list is almost always updated, then it is logical to just check the new list of servers ... But in my opinion, it is most often easier to make the player update himself ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question