Search code examples
javagoogle-app-enginechannel-api

How to make a countdown timer on appengine?


I am developing an application (on GAE) that needs a countdown timer and notifies the client side when the timer reaches zero.

To notify the client side i'm using GAE Channel API .

any ideas? (Considering GAE limitations. not using Thread or Timer from Java API).


Solution

  • I don't know how much reliability/precision you need, anyway here are a couple of ideas:

    1. After saving the server local time on memcache with the respective client ID, send a "timer-start" message to the client through the Channel API handling it client-side via some Javascript counter. When the timer is over or client has completed its duties , call the server and do your business logic.

    2. Use the countdown parameter of the TaskQueue, and before sending the "timer start" message to the client, add a task with a given countdown. The added task after n seconds will be triggered and should send the "timer-over" message to the client.