update comments in timer modules

This commit is contained in:
AlecM33
2022-01-11 22:54:48 -05:00
parent f5c0984211
commit 7e4083f097
3 changed files with 9 additions and 2 deletions

View File

@@ -3,7 +3,8 @@ A timer using setTimeout that compensates for drift. Drift can happen for severa
https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#reasons_for_delays
This means the timer may very well be late in executing the next call (but never early).
This timer is accurate to within a few ms for any amount of time provided. It's meant to be utilized as a Web Worker.
This timer is accurate to within a few ms for any amount of time provided. This is the client-side version of this module,
and is meant to be utilized as a Web Worker.
See: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API
*/

View File

@@ -20,7 +20,6 @@ const game = () => {
toast('Disconnected. Attempting reconnect...', 'error', true, false);
});
socket.on('connect', () => {
console.log('fired connect event');
socket.emit(globals.COMMANDS.GET_ENVIRONMENT, function (returnedEnvironment) {
timerWorker = new Worker(new URL('../modules/Timer.js', import.meta.url));
prepareGamePage(returnedEnvironment, socket, timerWorker);

View File

@@ -1,3 +1,10 @@
/*
A timer using setTimeout that compensates for drift. Drift can happen for several reasons:
https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#reasons_for_delays
This means the timer may very well be late in executing the next call (but never early).
This timer is accurate to within a few ms for any amount of time provided.
*/
function stepFn (serverTimerInstance, expected) {
const now = Date.now(); //