Vixen
02b45cc4
csharp
public sealed class ConnectionBaseline

What one connection is known to have, and what it has only been sent.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The difference between those two is the whole of delta replication over an unreliable channel. A value that was sent may be in a packet that never arrived; only a value that was acknowledged may be assumed to be there. So a send records what it sent against the tick it sent it at, and nothing enters the baseline until an ack for that tick comes back.

The consequence is the behaviour the design asks for and is easy to get wrong: on loss, the next snapshot is computed against the older baseline rather than resending the lost packet. The client gets the current value, not the one it missed — which is both cheaper and more correct, because the value it missed is stale by now.

Unacked ticks are bounded. Past MaxPendingTicks the oldest is dropped without entering the baseline, which is exactly right: a tick that old was lost, and forgetting that we sent it is what makes it be sent again.

Fields and properties (5)

  • public const int MaxPendingTicks

    How many unacknowledged ticks are kept before the oldest is given up on.

  • public Tick AcknowledgedTick

    The newest tick this connection has acknowledged.

  • public bool HasAcknowledged

    Whether anything has been acknowledged at all.

  • public int BaselineCount

    How many component values this connection is known to hold.

  • public int PendingTickCount

    How many ticks have been sent and not yet acknowledged.

Methods (7)

  • public bool IsCurrent(in BaselineKey key, uint hash)

    Whether a value is one this connection is known to already have.

  • public bool TryGetBaseline(in BaselineKey key, out Tick capturedAt, out uint hash)

    Which capture of a value this connection has acknowledged, so a difference can be measured from it.

  • public bool WasSentRecently(in BaselineKey key, uint hash, Tick now, int within)

    Whether this exact value has gone out recently enough that it could still be in flight.

  • public void RecordSent(Tick tick, in BaselineKey key, uint hash, Tick capturedAt)

    Records that a value went out in a snapshot.

  • public bool Acknowledge(Tick tick)

    Takes an acknowledgement, folding everything up to it into the baseline.

  • public void Forget(NetworkId id)

    Forgets an entity, because it was destroyed or left this connection's interest.

  • public void Clear()

    Forgets everything, for a connection that is starting again.

Used by (4)

  • ConnectionVixen.Net
  • DeltaTestsVixen.Net.Tests
  • ReplicationServerVixen.Net
  • ReplicationTestsVixen.Net.Tests