Answer the question
In order to leave comments, you need to log in
How to make multiple independent timers per user in NodeJs?
The task is this.
On the site, people play with each other in different rooms. When someone joins another user in a room, a 10 second timer should start for that particular room.
Here is the code:
gameTimer1v1(gameData.gid, '10');
function gameTimer1v1(gameid, timer)
{
roundGTimer = timer;
thisTimer = setInterval(function()
{
roundGTimer--
console.log(""+gameid+" - "+roundGTimer+"");
if (roundGTimer == 0)
{
clearInterval(this);
return false;
}
}, 1000);
}
Answer the question
In order to leave comments, you need to log in
Add a field to the room when the event should occur and do a check on this field. As an option.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question