0

I am working on an app that has a javascript interval timer. I would like the timer to run on a server then I would like to grab that time on multiple devices on click.

Ex: Countdown Timer to be displayed on a large screen in a gym (this is coming from the server). I would like users on mobile devices to be able to capture time and record it in real-time.

If the timer on the big screen said 10:35 when I push the button on my mobile device I want it to grab 10:35 and put it into an input field.

I have the timer code figured out. I just don't know how to get the time that is displayed on the server to the other devices.

I know that this is a very general question. I am just wondering if it is possible, and if someone can point me in the right direction.

Thanks!!!

2 Answers2

2

If you are using javascript/using node.js...you can use websockets to synchronize your timers in real time.

here is a link to a good tutorial :-) http://www.youtube.com/watch?v=pNKNYLv2BpQ

StaleMartyr
  • 778
  • 5
  • 18
0

Hmmm. This is a particularly difficult problem given the intricacies of keeping time in sync across multiple devices.

Here's the architecture I'd suggest:

  • The server serves an HTML document to the clients that contains three timestamps: the start time, the end time, and the current server time. This could conceivably be fetched over AJAX.
  • From the current server time, the client can calculate its current skew and display a countdown timer matching the server ("big board") using client-side Javascript.
  • A button could then grab the value of a timer and populate the input field.

Here's a pretty similar question.

Community
  • 1
  • 1
Christian Ternus
  • 8,406
  • 24
  • 39