S
S
Sedbol2020-02-22 16:34:30
JavaScript
Sedbol, 2020-02-22 16:34:30

Solution with timers?

Can you give me a solution with timers? Maybe I'm repeating myself deeply sorry for this. But in this case, you need a solution or, say, the implementation of the plan. The next task is to send a timer from the server that counts seconds and sends them to the socket to the client. Everything seems to be simple but. How to make a timer for each room in a socket? For example, there is a room in which there can be 4 people. If less than 3 people remain in this room, then the timer must be deleted.
As I wrote above, I asked this question here and the answers I answered there with a solution, it seems to be true logically, everything is like that . That's actually this question .
The thing is, as I wrote above, no more than 4 people can be in the room. If there are more then the server creates the next room. Example in room [1]=>4 people, 5th user came to the resource. The server will create a room [2] where 5 actually goes. The timer will need to be started when there are more than 3 people in room [2], and if there are less than three, then the timer must be deleted. How can this be implemented? I tried to send UNIX to the client on the client, but it turns out that the synchronization of which network response is long, for which the browser takes a long time to load. And it turns out for one the timer stopped ticking for someone. Why and how I think it is necessary to give a countdown from the server. The timer was created by an object and given away, but it is problematic to remove it. How can this be done?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2020-02-22
@Sedbol

Each time you connect a socket, create a timer and throw it off only to the socket, and not to everyone, it’s not io.emit, but socket.emit (on the server).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question