Foundry Virtual Tabletop - API Documentation - Version 14
    Preparing search index...

    A singleton class at which keeps the official Server and World time stamps. Uses a basic implementation of https://www.geeksforgeeks.org/cristians-algorithm/ for synchronization.

    Index

    Properties

    SYNC_INTERVAL_MS: number = ...

    The amount of time to delay before re-syncing the official server time.

    Accessors

    • get averageLatency(): number

      The average one-way latency between client and server in milliseconds.

      Returns number

    • get serverTime(): number

      The current server time based on the last synchronization point and the approximated one-way latency.

      Returns number

    • get worldTime(): number
      • The current World time expressed in seconds.

      Returns number

    Methods

    • Advance or rewind the world time according to a delta amount expressed either in seconds or as components.

      Parameters

      • delta: number | TimeComponents

        The number of seconds to advance (or rewind if negative) by

      • Optionaloptions: object

        Additional options passed to game.settings.set

      Returns Promise<number>

      The new game time

    • Initialize a calendar configuration. This is called once automatically upon construction, but can be called manually if CONFIG.time changes.

      Returns void

    • Handle follow-up actions when the official World time is changed

      Parameters

      • worldTime: number

        The new canonical World time.

      • options: object

        Options passed from the requesting client where the change was made

      • userId: string

        The ID of the User who advanced the time

      Returns Promise<void>

    • Directly set the world time to a certain value expressed either in seconds or as components.

      Parameters

      • time: number | TimeComponents

        The desired world time

      • Optionaloptions: object

        Additional options passed to game.settings.set

      Returns Promise<number>

      The new game time

    • Synchronize the local client game time with the official time kept by the server

      Returns Promise<GameTime>