I'm developing a card game server. I want to do this : While server process a turn for players, players have 20 seconds to do something. If players send a request to server within 20 secs, timer will stop and the callback will fire.
I'm doing like this :
self.tables[table.id].currentTimer = setTimeout(function () { callback(); }, 20*1000);
How should I run the callback before delay time exceeded ?