Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ClockSync

Clock syncer's goal is to keep a local clock in sync with a server clock.

It does this by sampling the server time a few times and then monitoring the local clock for any time disturbances. Should these occur it will re-sample the server.

After the sample period it is able to provide a delta value for its difference from the server clock, which can be used to make time based adjustments to local time based operations.

Hierarchy

  • EventEmitter
    • ClockSync

Index

Constructors

constructor

Properties

state

state: ClockSyncerState = ClockSyncerState.Stopped

Static defaultMaxListeners

defaultMaxListeners: number

Methods

addListener

  • addListener(event: string | symbol, listener: Function): this
  • Parameters

    • event: string | symbol
    • listener: Function

    Returns this

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): (string | symbol)[]
  • Returns (string | symbol)[]

getDelta

  • getDelta(forceCalculation?: boolean): number
  • Gets the current delta value from the synchronizer.

    Parameters

    • Optional forceCalculation: boolean

    Returns number

getMaxListeners

  • getMaxListeners(): number
  • Returns number

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

on

  • on(event: string | symbol, listener: Function): this
  • Parameters

    • event: string | symbol
    • listener: Function

    Returns this

once

  • once(event: string | symbol, listener: Function): this
  • Parameters

    • event: string | symbol
    • listener: Function

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: Function): this
  • Parameters

    • event: string | symbol
    • listener: Function

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: Function): this
  • Parameters

    • event: string | symbol
    • listener: Function

    Returns this

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: Function): this
  • Parameters

    • event: string | symbol
    • listener: Function

    Returns this

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

start

  • start(): void
  • Starts the clock synchronizer. It will emit delta events, when it is able to calculate the delta between the client and the server.

    Returns void

stop

  • stop(): void

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Generated using TypeDoc