Syncing big data

Using fragmented channels to synchronize data that wouldn't usually fit in a packet.

Synchronizing entities with byte[] or string bindings, or sending commands with byte[] or string arguments allows you to sync large amounts of custom data, but if an entity update, or a single command, is too large to fit inside a single packet (where default MTU is 1280 bytes), then the entity update or the command will never be synchronized. To solve this problem, and be able to sync data of practically any size, you can use fragmented channels for synchronization of entities or commands.

Syncing big data over entity bindings

In the Advanced Settings of the CoherenceSync, you can change the Synchronization Channel of an entity. Choosing the Fragmented channel will synchronize creation, deletion, and all binding updates of the entity over the Fragmented channel, allowing you to sync data of any size.

Note that the commands targeting that entity will still be sent over any channel. See commands section for more details.

Syncing big data over commands

You can send commands over the fragmented channel to any entity, no matter if the entity is synchronized over the Fragmented or Default channel. To send a command over the fragmented channel, use the SendCommandOverChannel(...) and SendCommandToChildrenOverChannel(...) overloads, passing either Fragmented or FragmentedOrdered channel (for ordered commands) as an argument.

var data = new byte[1024 * 1024]; // 1 MB of data
sync.SendCommandOverChannel<Player>(
    nameof(Player.SendData),
    MessageTarget.AuthorityOnly,
    Channel.Fragmented,
    data);

Last updated

Was this helpful?