Skip to content

arasmussen/Socket.io-time-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

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

No packages published