public sealed class ReplicationServerTurns a world into a snapshot per connection, once a tick.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
The shape of a tick is Capture then one TryWriteSnapshot per connection, and the split is the point. Capture reads the world, quantizes and packs each component that changed, and does it once; a snapshot is then a copy of those bits for the connections that do not already have them. Fifty players cost fifty memcpys and one encode, rather than fifty encodes.
What to send is decided by comparison, not by a dirty flag. The ECS's per-chunk change versions say which chunks are worth looking at — the cheap filter, and the main structural reason for having built an ECS with them — and a hash of the encoded value says which entities within those chunks actually differ from what this connection has acknowledged. The first is O(chunks) and skips almost everything; the second is exact.
The budget sheds rather than truncates. Records are written in priority order and the writer is rewound if one would take the snapshot over the budget, so a snapshot is always a whole number of complete records. What was shed was never acknowledged, so it is simply included in the next one — the loss and the shed take the same path out.
Fields and properties (12)
public const int BaselineAgeBitsHow many bits name which capture a difference was measured from, counted back from the one it produces.
public const int MaxBaselineAgeThe furthest back, in ticks, a difference may be measured from.
public BandwidthBudget BudgetHow much each snapshot may cost.
public int ResendDelayTicksHow long a record is assumed to be travelling before it is worth sending again.
public long SuppressedRecordCountRecords not sent because the same value was already on its way.
public IReplicationRate? RateHow often each object is worth sending, or null for every object every tick.
public long RateSkippedRecordCountRecords not written because the object was not due this tick.
public BandwidthLedger? LedgerWhere the bandwidth went, or null to not ask.
public int TrackedValueCountHow many component values are being tracked across every entity.
public int LastCapturedCountWhat was captured at the last Capture.
public long DeltaRecordCountRecords sent as a difference from the value the connection already held.
public long WholeRecordCountRecords sent whole, because the connection did not hold the value the difference was measured from — or because the component does not declare a layout to difference over.
Methods (7)
public ReplicationServer(ReplicationRegistry registry, IInterestResolver? interest = null)Creates a server-side replicator.
public void Capture(World world, Tick capturedAt = default(Tick))Reads everything that changed since the last call, and encodes it once.
public bool TryWriteSnapshot(World world, PlayerId player, Tick tick, Span<byte> buffer, out ReadOnlySpan<byte> snapshot)Writes one connection's snapshot.
public void Acknowledge(PlayerId player, Tick tick)Takes a client's acknowledgement of a snapshot it applied.
public void Despawn(NetworkId id)Stops tracking an entity, and tells everybody holding it to drop it.
public void Forget(PlayerId player)Forgets a connection entirely.
public ConnectionBaseline BaselineOf(PlayerId player)What a connection is known to hold, for diagnostics and for tests.
Used by (15)
- ArenaMultiplayer
- GameServerMultiplayer
- SoakNetworkSoak
- BitExactnessTestsVixen.Net.Tests
- DeltaTestsVixen.Net.Tests
- DiagnosticsTestsVixen.Net.Tests
- NetworkMetricsVixen.Net
- NetworkSpawnTestsVixen.Net.Engine.Tests
- NetworkSpawnerVixen.Net.Engine
- ReplicationClientVixen.Net
- ReplicationTestsVixen.Net.Tests
- SnapshotInspectorVixen.Net
- SnapshotSeedsVixen.Net.Fuzz
- SyncListReplicationTestsVixen.Net.Engine.Tests
- SyncStateTestsVixen.Net.Engine.Tests