arangace / CreamCat

SOFTENG750 project team CreamCat
MIT License
0 stars 3 forks source link

Latency compensation between server and clients #69

Closed nivekyee closed 3 years ago

nivekyee commented 3 years ago

Since we are there is a delay between each socket-io emit and receive between server and clients, the clients currently play music with a slight delay between them. To counter this, an emitTime value can be included in the message which when paired with a receivedTime value generated from on the receiving end, can be used to calculate the latency for each socket communication. This latency can then be used to compensate for the delayed elapsedTime passed on the connection handshake when a new client joins (received elapsedTime + latency = actual elapsedTime)

nivekyee commented 3 years ago

Dayjs is used to get the local time from the endpoints, need error detection for when the local time is incorrectly set and error handling for when the latency is too high