Skip to main content

TimeSyncService

Syncronizes time between the server and client. This creates a shared timestamp that can be used to reasonably time events between the server and client.

Functions

Init

TimeSyncService:Init() → ()

Initializes the TimeSyncService

IsSynced

TimeSyncService:IsSynced() → boolean

Returns true if the clock is synced. If the clock is synced, then it can be retrieved.

WaitForSyncedClock

This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. Yields
TimeSyncService:WaitForSyncedClock() → MasterClock | SlaveClock

Waits for the synced clock, or throws an error.

GetSyncedClock

TimeSyncService:GetSyncedClock() → MasterClock | SlaveClock | nil

Returns a synced clock if there is one available. Otherwise, returns nil.

PromiseSyncedClock

TimeSyncService:PromiseSyncedClock() → Promise<MasterClock | SlaveClock>

Promises a synced clock

Destroy

TimeSyncService:Destroy() → ()

Cleans up the time syncronization service.

Show raw api
{
    "functions": [
        {
            "name": "Init",
            "desc": "Initializes the TimeSyncService",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 31,
                "path": "src/timesyncservice/src/Shared/TimeSyncService.lua"
            }
        },
        {
            "name": "IsSynced",
            "desc": "Returns true if the clock is synced. If the clock is synced, then it can\nbe retrieved.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 58,
                "path": "src/timesyncservice/src/Shared/TimeSyncService.lua"
            }
        },
        {
            "name": "WaitForSyncedClock",
            "desc": "Waits for the synced clock, or throws an error.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "MasterClock | SlaveClock"
                }
            ],
            "function_type": "method",
            "yields": true,
            "source": {
                "line": 73,
                "path": "src/timesyncservice/src/Shared/TimeSyncService.lua"
            }
        },
        {
            "name": "GetSyncedClock",
            "desc": "Returns a synced clock if there is one available. Otherwise, returns nil.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "MasterClock | SlaveClock | nil"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 87,
                "path": "src/timesyncservice/src/Shared/TimeSyncService.lua"
            }
        },
        {
            "name": "PromiseSyncedClock",
            "desc": "Promises a synced clock",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<MasterClock | SlaveClock>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 105,
                "path": "src/timesyncservice/src/Shared/TimeSyncService.lua"
            }
        },
        {
            "name": "Destroy",
            "desc": "Cleans up the time syncronization service.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 159,
                "path": "src/timesyncservice/src/Shared/TimeSyncService.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "TimeSyncService",
    "desc": "Syncronizes time between the server and client. This creates a shared timestamp that can be used to reasonably time\nevents between the server and client.",
    "source": {
        "line": 7,
        "path": "src/timesyncservice/src/Shared/TimeSyncService.lua"
    }
}