Skip to content

Extended ElementData Sync #638

Open
Open
@Pirulax

Description

@Pirulax

Trying a lot of different techniques to sync data between server and clients i'm always facing bandwidth and cpu drops on server-side or fps-drops on clientside.

Summarizing my experience, i would like to suggest a feature, something like

setElementDataEx(element, key, value, syncType=normal, syncTargets = root, forceSync=true)
forceElementDataSync()

This function should work in conjunction with the classic elementData, but the difference is how things will be synchronized.

syncType:

  1. only players listed in syncTargets will receive the update. if new player joins or reconnects the server, the date is hidden for him, but if same key and same value will be set targeting to this player, he should receive the update.

  2. normal - direct update will receive only syncTargets, sets data as public, if new player join the server, he should receive this data as well.

  3. stream - this data should be synchronized only when player streams the element or element already streamed in. syncTargets is ignored here, but can be used to filter players who should receive data when element streamed. When element streams out, the data should stay in memory, so next time only delta will be synced. (it's a little bit tricky, we need to store some timestamp of last sync, but it will save a bandwidth and cpu.)

forceSync:
if true - data should be directly sent like setElementData, if false - the MTA should push it into buffer and collect all changes until current scope ends or method forceElementDataSync() triggered. This means the data should be synchronized not like many single packets, but one batch operation, or can be splitted in to few buckets for better shipping and client-side processing. The order of operations should be keeped. If newly set value overlaps previously set one in pending buffer, it should be overwritten.

forceElementDataSync() - forces operations buffer to be synced.

p.s. i know that most of it can be done on lua side, but there is a few limitations with setElementData without sync, which forces you to keep a duplicated element data tree. Actually i already did most of it in lua, but some of operations causing FPS drops due to lua quickness, so i think it should be implemented closely to core :)

From mantis.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions