ITimeSmoother

class timeSmoother.ITimeSmoother()

A utility class used to smooth out a time value (a plain number in seconds) based on sporadic reporting and using the client clock to fill in the holes in realtime.

The user should call set(time) once in a while to assign the current time. This specified time will be linked to the client’s current clock (which can be overriden as a second parameter). If the specified time is identical to what was previously set, it will be ignored and nothing happens.

The user can then call get() multiple times, and the current client clock will then be used to offset that timestamp in real time. Again, the client clock can be overridden by sending a client timestamp parameter to get().

When overriding the client_timestamp, the structure is expected to be a Date() instance, and is only meant to avoid calling ‘new Date()’ internally.

The max estimation duration is the number of seconds after which the get() call will stop estimating the duration. It is set to Infinity by default (i.e. disabled).

Methods

timeSmoother.ITimeSmoother.get(client_timestamp)
Arguments:
  • client_timestamp – Date
Returns:

any

timeSmoother.ITimeSmoother.set(time, client_timestamp)
Arguments:
  • time – any
  • client_timestamp – Date
Returns:

any

timeSmoother.ITimeSmoother.set_get(time, client_timestamp)
Arguments:
  • time – any
  • client_timestamp – Date
Returns:

any

timeSmoother.ITimeSmoother.set_max_estimation_duration(duration)
Arguments:
  • duration – number
Returns:

any