Hacker News new | ask | show | jobs
by Wolfmans55 702 days ago
So overall, the site including the buzzer page uses websockets for (close to) real-time client-server communication.

Obviously latency can be an issue, so my non-perfect B+ solution is to essentially calculate the round trip of the buzz, divide it by 2, and subtract it from the server time.

client ------------ pingTime ------------> server

client <----------- serverTime ----------- server

roundTrip = pingTime + pongTime

buzzTime = serverTime - (roundTrip / 2);

The server time is always the source of truth since client times can vary. Not using NTP which could possibly be more accurate.