tags:

views:

59

answers:

2

I want to create a single timer that is displayed on my site, I want for it to be synchronous across all clients trying to access it. When a client clicks the "increase" button, I want the timer to add 1 minute to the countdown and I want this change to be reflected for all clients.

Is this achievable through PHP? Any tips/advice to get me started?

Thank you!

A: 

Yes it can be done, but you need some delayed AJAX, the same technology used to created javascript chat windows, realtime logging etc.

CMartins
+1  A: 

If you want a click from any client to effect all clients you will need to base the solution either on Polling (refreshing an AJAX hit) or Comet programming. A comet programming solution is more complex, but allow you to push the timer updates to all the clients in real time.

Word of Advice: Unless your website is planning on doing a large amount of asynchronous communication, I'd just stick with a simple polling solution. You could even have the AJAX poll a static file and update the static file via PHP (this updating needs to be done atomically). This means each AJAX poll will be very cheap.

Kendall Hopkins