-
Notifications
You must be signed in to change notification settings - Fork 0
Relevant socket.io code to sync time between client and server
License
arasmussen/Socket.io-time-sync
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
It's very common that in real-time games and applications, you need to know which of two events took place first. While the server's time should be authoritative since nothing can be trusted from clients, sometimes this calculation must be done on the client. Setting the client's time to be the same as the server's is usually out of the question. A much better approach is to find the difference between the server's time and each client's time, and store that on the client. This difference can be added to all client times to convert them to server times. This repo makes it easy for clients to learn the relative difference between its own time and the server's time by sending a message to the server containing the time the message was sent and the server sending back the difference. This process is done a few times to ensure accuracy.
About
Relevant socket.io code to sync time between client and server
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published