How to do: Countdown timer with milliseconds

#1

Hi guys. Not sure if this is the right place to ask it, and maybe it can sounds totally newby but…

Im looking for a Countdown timer, what includes milliseconds. And get that time, from the server to the client.

I did a countdown timmer before, in meteor. But i didnt found any way to get milliseconds from the server to the client.

Could be a way to do this with Jquery Countdown library? Or any other meteor package?

How can i aprroach this situation? Someone knows a package, or some easy way to create a countdown, and get the milliseconds to the client? Like 00:59:99 Or something like this.

Thanks! And sorry for this newby question!

Synchronous countdown
#2

I don’t think people do that on millisecond basis. Here’s how it usually goes.

  1. Server sends time to client
  2. Client syncs time with any offset from the server
  3. Client starts counting down using setInterval on 1 ms
  4. Client pings server every n seconds to make sure that they are still in sync
    • Server might also push a sync time to the client to save a roundtrip

Basically the client mimics and the server double checks

2 Likes
#3

Although i’m an expert in some areas, i’m a complete noob in other areas. Thats why we have forums. The reason I know the answer is because I faced the same issue a couple of years ago for an auction app.

Its just impossible to know everything

Daring to ask is actually a strong trait so i find it unfortunate that you removed your question.now others with the same problem need to look elsewere and might not find it :frowning:

2 Likes
#4

@Hanna_92 : I fully agree with this and add that removing your question also devalues the time and effort that’s been put in to answer it. For reference, I’ll copy the original question here in case anyone else faces a similar problem:

Hi guys. Not sure if this is the right place to ask it, and maybe it can sounds totally newby but…

Im looking for a Countdown timer, what includes milliseconds. And get that time, from the server to the client.

I did a countdown timmer before, in meteor. But i didnt found any way to get milliseconds from the server to the client.

Could be a way to do this with Jquery Countdown library? Or any other meteor package?

How can i aprroach this situation? Someone knows a package, or some easy way to create a countdown, and get the milliseconds to the client? Like 00:59:99 Or something like this.

Thanks! And sorry for this newby question!

#5

Relax guys, question is back.

I just removed it cause i thought my question was a totally newby question, and not properly good for this forum.

Things are back, i dont killed anyone. And thanks @cloudspider for the time u spend on it, and the effor u did answering.

2 Likes
#6

Just to close the loop on this: maintaining close synchronisation of client time with server time is difficult. Each browser will have latency (roundtrip time) between it and the server. In development this is usually insignificant, but in production with clients in different locations and on different networks, there are often wildly different latencies. Computing and maintaining synchronisation is a challenge. However, there is a package which does a good job of this in a very Meteor way: mizzao:timesync - it may be good enough for your needs :slight_smile:.

2 Likes
#7

Thanks, that’s right, I saw that package before, I should take a look at it.