How do I synchronize multiple devices so that they fire simultaneously at a particular time?

PubNub provides a time API which can be used to synchronize clients (each having its own latency) within a millisecond of each other. This can be done by creating a minimum buffer amount of time (wait time) for which all devices agree to move forward after acknowledging the signal.     

Follow these basic steps to sync devices with independent latencies:

  1. determine the local time (in milliseconds): start = now()
  2. load the server timetoken: timetoken =
  3. calculate the delay latency for a timetoken request: delay = now() - start
  4. convert server timetoken into miliseconds: timetoken = timetoken/10000
  5. add a delay to compensate for latency: client_time = timetoken + delay

Use client_time to synchronize all devices to fire at a particular clock time.  

NOTE: this is just a basic mechanism to lockstep-synchronize devices with independent latency connections. A full solution will need to customize the above mechanism to match your needs. The clock will need to be re-synchronized each time the app boots.