Hello everyone,
I am trying to implement a server side digital clock, like the one You will use to play chess. It’s a little bit more complicated that it might appear, because there are a lot of different time controls. I will also need to check for network latency.
eg: fischer clock, bioyomi time, absolute time etc.
I would like to know if You have heard of some librabries that could help me solve this problem. I thought it would be useful to all game related server, but could not find any packages, both in Elixir or Erlang.
Otherwise, I think Elixir is a great fit to solve this.
Greetings
1 Like
Is it over TCP? UDP? HTTP?
It will be over websocket
Cool, so ‘basically’ tcp once established. I don’t know of any timing libraries to guess the amount of latency off hand, but it would not be hard to make, just set a heartbeat to bounce back and forth with detailed timestamps and calculate it from that. Keep it going however often you want to account for how latency changes (if you expect it to be on wired then once every 10 minutes is probably fine, if over wifi then probably once every 10/30 seconds, if mobile, well good luck ^.^;).
Then based on the latest detected latency just subtract that from the time when you get the message.
I am guessing there will be multiple connections with a single timer. If only a timer per connection, well just let the client use their own time unless you have cheating issues or something.
3 Likes
@OvermindDL1 Thank You for your reply. I was thinking about a similar solution, but yours is more precise.