TimeSync
TimeSync is a tool for measuring the latency and clock offset between your NetsBlox client and the NetsBlox server. This can be used to have more precise timings for message passing and other time-based synchronization tasks.
To use this service, you first call TimeSync.prepare()
, followed by performing several (e.g., 100) calls
to TimeSync.step()
, and then finishing with TimeSync.complete()
to get the computed timing metrics.
Note that the calls to TimeSync.step()
are intended to be back-to-back.
You should perform this in a loop that does nothing else.
In particular, you should not sleep/wait inside the loop; if you need this,
you may provide a sleepTime
to TimeSync.prepare()
and it will do the sleeping/waiting for you (do not also sleep yourself).
RPCS
- TimeSync.complete()
Completes a timing operation started by
TimeSync.prepare()
and returns the summarized timing metrics.Returns:
Object
(Object) - Information about the computed timing metrics.
- TimeSync.prepare(sleepTime: BoundedNumber<0, 1>?)
Prepares to receive a new sequence of time steps. The return value of this RPC includes the minimum and maximum number of times
TimeSync.step()
must be called before callingTimeSync.complete()
.Arguments:
sleepTime: BoundedNumber<0, 1>?
(BoundedNumber) - Amount of time (in seconds) to automatically wait between steps (default0.1
).
Returns:
Object
(Object) - Information about the min and max number of steps that can be performed.
- TimeSync.step()
Adds a time step to the data pool. You must call
TimeSync.prepare()
before calling this RPC.