SyncedNetworkData
Index
Constructors
Methods
- addOnDataChangedListener
- addVerifier
- apply
- fromJSON
- getBoolean
- getClients
- getDouble
- getFloat
- getGlobalVerifier
- getInt
- getLong
- getName
- getObject
- getString
- isServer
- putBoolean
- putDouble
- putFloat
- putInt
- putLong
- putObject
- putString
- removeAllListeners
- removeOnDataChangedListener
- sendChanges
- sendChangesForClient
- setClients
- setGlobalVerifier
- toJSON
- getClientSyncedData
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
Adds event that catches changes of any data values on both sides.
Parameters
listener: OnDataChangedListenerFunction
Returns void
addVerifier
Adds server-side data transformer received from client to the object by specified key.
Parameters
key: string
verifier: DataVerifierFunction
Returns void
apply
Same as SyncedNetworkData.sendChanges.
Returns void
fromJSON
Replaces existing data with those that are in given object.
Parameters
json: string
serialized object data
Returns void
getBoolean
Parameters
key: string
optionalfallback: boolean
Returns boolean
Requested value by key or fallback if key not found.
getClients
Returns NetworkConnectedClientList
Connected client list, which receive this data.
getDouble
Parameters
key: string
optionalfallback: number
Returns number
Requested value by key or fallback if key not found.
getFloat
Parameters
key: string
optionalfallback: number
Returns number
Requested value by key or fallback if key not found.
getGlobalVerifier
Global verifier that was set via SyncedNetworkData.setGlobalVerifier.
Returns DataVerifierFunction
getInt
Parameters
key: string
optionalfallback: number
Returns number
Requested value by key or fallback if key not found.
getLong
Parameters
key: string
optionalfallback: number
Returns number
Requested value by key or fallback if key not found.
getName
Returns string
Name passed in constructor, which one will be used for packets.
getObject
Parameters
key: string
Returns Object
Requested value by key or null if key not found.
getString
Parameters
key: string
optionalfallback: string
Returns string
Requested value by key or fallback if key not found.
isServer
Returns boolean
true
if it was server-side data that can be sent to clients.
putBoolean
Sets Boolean value by key.
Parameters
key: any
value: boolean
Returns void
putDouble
Sets Double value by key.
Parameters
key: any
value: number
Returns void
putFloat
Sets Float value by key.
Parameters
key: any
value: number
Returns void
putInt
Sets Integer value by key.
Parameters
key: any
value: number
Returns void
putLong
Sets Long value by key.
Parameters
key: any
value: number
Returns void
putObject
Sets Object value by key.
Parameters
key: string
value: Object
Returns void
putString
Sets String value by key.
Parameters
key: any
value: string
Returns void
removeAllListeners
Removes all data change events, that was registered by SyncedNetworkData.addOnDataChangedListener before.
Returns void
removeOnDataChangedListener
Removes data change event, that was registered by SyncedNetworkData.addOnDataChangedListener before.
Parameters
listener: OnDataChangedListenerFunction
Returns void
sendChanges
Sends changed data values.
Returns void
sendChangesForClient
Sends changed data values for specific client (dirty data remains).
Parameters
client: NetworkClient
connected client to server
Returns void
setClients
Overrides connected client list, new one will automatically send server data.
Parameters
clients: NetworkConnectedClientList
Returns void
setGlobalVerifier
Adds server-side data transformer received from client that will be used if there is no verifier with specified key registered via SyncedNetworkData.addVerifier.
Parameters
verifier: DataVerifierFunction
Returns void
toJSON
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.
Class to work with values, synchronized between server and all clients.