user1971989
user1971989

Reputation: 121

how to synchronize countdown timer to all user

I am developing a countdown timer app. User can register the app and share their own countdown timer; However, I have a problem here, how to let all user synchronize the same countdown timer? I use Angular and NodeJS + MongoDB to develop this app. My problem is the countdown timer is running by angularjs that only one user can see the running timer, but other people can't. Should I update every second number in database and query it every second or running timer in the backend?

any suggestion ?

Upvotes: 1

Views: 1049

Answers (1)

Buzz Moschetti
Buzz Moschetti

Reputation: 7578

I'd do it this way: When the timable action occurs server-side, store both the start time and the end time in the database. Upon page load, both numbers get pulled to the client, which figures out the delta and starts its own local countdown. The GUI can optionally show the server-side end time, which is the "time of record."

Upvotes: 1

Related Questions