Vertex Viewer SDK
    Preparing search index...

    Class SynchronizedClock

    A SynchronizedClock allows for approximating the time on a remote machine.

    During initialization, a known time of the remote host must be supplied. Once the remote time is known, this class can approximate the time on the remote machine from a date or duration.

    const knownRemoteTime = await getRemoteTime();
    const clock = new SynchronizedClock(knownRemoteTime);

    const localDate = new Date();
    const serverTime = clock.remoteTime(localDate);

    const remoteDate = await getRemoteTime();
    const localTime = clock.localTime(remoteDate);

    const currentRemoteTime = clock.remoteNow();
    Index

    Constructors

    Properties

    knownLocalTime: Date = ...
    knownRemoteTime: Date

    Methods

    • Approximates the local time from a timestamp originating from the remote machine.

      Parameters

      • remoteTime: Date

        A remote timestamp.

      Returns Date

    • Approximates the local from an offset duration originating from the remote machine's last known time.

      Parameters

      • remoteDurationInMs: number

        A remote duration, in milliseconds.

      Returns Date