Skip to content

Efficiently syncing data between the server and client (or vice versa) #20

@SABogdan

Description

@SABogdan

Goal

Efficient synchronization of data between the server and client (or vice versa).
This data CAN include dictionaries, lists, and classes.
The current process of synchronization is inefficient, cumbersome and not optimal as it is time-consuming and can lead to performance issues, especially when dealing with large datasets as it involves converting these complex data structures into JSON strings and then parsing them back into their original form.
Example:

//server
public Dictionary<int, someClass> _serverDictonary = new Dictionary<int, someClass>();
public void serverFunction()
{
..some logic
TriggerClientEvent("someEvent", Json.Stringify(_serverDictonary));
}

//client
public Dictionary<int, someClass> _clientDictonary = new Dictionary<int, someClass>();
[EventHandler("someEvent")]
public void OnSync(string json) 
{
 _clientDictonary = Json.Parse<Dictionary<int, someClass>>(json);
..some logic
}

Importancy

Quality of Life (QoL)

API and/or potential implementation

// Server
public Dictionary<int, someClass> _serverDictionary = new Dictionary<int, someClass>();

public void ServerFunction()
{
    // ... some logic ...
    
    TriggerClientEvent("someEvent", _serverDictionary);
}

// Client
public Dictionary<int, someClass> _clientDictionary = new Dictionary<int, someClass>();

[EventHandler("someEvent")]
public void OnSync(Dictionary<int, someClass> serverData) 
{
    _clientDictionary = serverData;
    
    // ... some logic ...
}

Extra

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions