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:
- determine the local time (in milliseconds):
start = now()
- load the server timetoken:
timetoken = http://pubsub.pubnub.com/time/0
- calculate the delay latency for a timetoken request:
delay = now() - start
- convert server timetoken into miliseconds:
timetoken = timetoken/10000
- add a delay to compensate for latency:
client_time = timetoken + delay
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.