Skip to content

Conversation

@nuubik
Copy link
Contributor

@nuubik nuubik commented May 28, 2025

Summary

  • add timesync support
  • gather three consecutive time sync samples
  • apply the smallest offset from those samples when offset exceeds 3s
  • document sequential time sync requests

}
var minOffset = Math.min.apply(null, timeSyncSamples);
timeSyncSamples = [];
if (Math.abs(minOffset) > 3000000000) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer the 3E9 syntax for large numbers. It is very annoying to count the zeros

}

function parseCurrentTimeResponse(serverTime) {
var localNs = Date.now() * 1000000;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here also 1E6

timeSyncSamples = [];
if (Math.abs(minOffset) > 3000000000) {
setTimeOffset(minOffset);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't there be an else clause to reset the offset for the case previously due to some network issue offset was very high but now is under 3 seconds?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants