Перейти к основному содержанию

SyncedNetworkData

Class to work with values, synchronized between server and all clients.

Index

Constructors

constructor

  • Constructs server network data by specified name, clients will receive data via instance with same contructor.


    Parameters

    • name: string

    Returns SyncedNetworkData

Methods

addOnDataChangedListener

addVerifier

  • Adds server-side data transformer received from client to the object by specified key.


    Parameters

    Returns void

apply

  • apply(): void

fromJSON

  • fromJSON(json: string): void
  • Replaces existing data with those that are in given object.

    @since

    2.3.1b116-3


    Parameters

    • json: string

      serialized object data

    Returns void

getBoolean

  • getBoolean(key: string, fallback?: boolean): boolean

  • Parameters

    • key: string
    • optionalfallback: boolean

    Returns boolean

    Requested value by key or fallback if key not found.

getClients

getDouble

  • getDouble(key: string, fallback?: number): number

  • Parameters

    • key: string
    • optionalfallback: number

    Returns number

    Requested value by key or fallback if key not found.

getFloat

  • getFloat(key: string, fallback?: number): number

  • Parameters

    • key: string
    • optionalfallback: number

    Returns number

    Requested value by key or fallback if key not found.

getGlobalVerifier

getInt

  • getInt(key: string, fallback?: number): number

  • Parameters

    • key: string
    • optionalfallback: number

    Returns number

    Requested value by key or fallback if key not found.

getLong

  • getLong(key: string, fallback?: number): number

  • Parameters

    • key: string
    • optionalfallback: number

    Returns number

    Requested value by key or fallback if key not found.

getName

  • getName(): string

  • Returns string

    Name passed in constructor, which one will be used for packets.

getObject

  • getObject(key: string): Object

  • Parameters

    • key: string

    Returns Object

    Requested value by key or null if key not found.

getString

  • getString(key: string, fallback?: string): string

  • Parameters

    • key: string
    • optionalfallback: string

    Returns string

    Requested value by key or fallback if key not found.

isServer

  • isServer(): boolean

  • Returns boolean

    true if it was server-side data that can be sent to clients.

putBoolean

  • putBoolean(key: any, value: boolean): void
  • Sets Boolean value by key.


    Parameters

    • key: any
    • value: boolean

    Returns void

putDouble

  • putDouble(key: any, value: number): void
  • Sets Double value by key.


    Parameters

    • key: any
    • value: number

    Returns void

putFloat

  • putFloat(key: any, value: number): void
  • Sets Float value by key.


    Parameters

    • key: any
    • value: number

    Returns void

putInt

  • putInt(key: any, value: number): void
  • Sets Integer value by key.


    Parameters

    • key: any
    • value: number

    Returns void

putLong

  • putLong(key: any, value: number): void
  • Sets Long value by key.


    Parameters

    • key: any
    • value: number

    Returns void

putObject

  • putObject(key: string, value: Object): void
  • Sets Object value by key.


    Parameters

    • key: string
    • value: Object

    Returns void

putString

  • putString(key: any, value: string): void
  • Sets String value by key.


    Parameters

    • key: any
    • value: string

    Returns void

removeAllListeners

  • removeAllListeners(): void

removeOnDataChangedListener

sendChanges

  • sendChanges(): void
  • Sends changed data values.


    Returns void

sendChangesForClient

  • Sends changed data values for specific client (dirty data remains).

    @since

    2.3.1b116-3


    Parameters

    Returns void

setClients

  • Overrides connected client list, new one will automatically send server data.


    Parameters

    Returns void

setGlobalVerifier

toJSON

  • toJSON(): string
  • @since

    2.3.1b116-3


    Returns string

    Serialized object data which are in object.

staticgetClientSyncedData


  • Parameters

    • name: string

    Returns SyncedNetworkData

    Registered client synced data by name or null if it was not yet received.