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 :func:`TimeSync.prepare`, followed by performing several (e.g., 100) calls to :func:`TimeSync.step`, and then finishing with :func:`TimeSync.complete` to get the computed timing metrics. Note that the calls to :func:`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 :func:`TimeSync.prepare` and it will do the sleeping/waiting for you (do not also sleep yourself). .. toctree:: :maxdepth: 2 :titlesonly: :caption: RPC Categories RPCS ---- .. function:: TimeSync.complete() Completes a timing operation started by :func:`TimeSync.prepare` and returns the summarized timing metrics. **Returns:** ``Object`` (`Object `__) - Information about the computed timing metrics. .. function:: 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 :func:`TimeSync.step` must be called before calling :func:`TimeSync.complete`. **Arguments:** - ``sleepTime: BoundedNumber<0, 1>?`` (`BoundedNumber `__) - Amount of time (in seconds) to automatically wait between steps (default ``0.1``). **Returns:** ``Object`` (`Object `__) - Information about the min and max number of steps that can be performed. .. function:: TimeSync.step() Adds a time step to the data pool. You must call :func:`TimeSync.prepare` before calling this RPC.