C#: receipt server follows Heimdall's review of #61
Some checks failed
CultMesh QUIC native / Build win32-x64 (pull_request) Has been skipped
CultMesh QUIC native / Build linux-x64 (pull_request) Has been skipped
CultMesh QUIC native / Release native binaries (pull_request) Has been skipped
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Failing after 5m30s
CultMesh QUIC native / Verify committed binaries match SHA256SUMS (pull_request) Successful in 21s

Look the id up first and authorize only on first sighting; remember refusals within the cap; never re-forward an id whose primary stayed silent; end the connection when an answer cannot be queued; fixed refusal texts; limit_reached cap refusal; commit-point doc on ApplyPut/Delete.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Libby 2026-11-08 14:32:39 +00:00
commit ed5f9d30d1
6 changed files with 362 additions and 118 deletions

View file

@ -3534,6 +3534,7 @@ namespace GameCult.Networking
public sealed class LiteNetLibTransportConnection
{
private readonly Action<byte[]>? _deliver;
private readonly Action? _end;
private readonly CultNetTransportStats _stats = new CultNetTransportStats();
/// <summary>
@ -3543,21 +3544,41 @@ namespace GameCult.Networking
{
if (peer == null) throw new ArgumentNullException(nameof(peer));
_deliver = payload => peer.Send(payload, DeliveryMethod.ReliableOrdered);
_end = peer.Disconnect;
Profile = profile ?? CultNetTransportProfiles.CreateLiteNetLib("csharp-litenetlib-peer");
}
// The mock point for what leaves the connection: the peer's reliable ordered send.
internal LiteNetLibTransportConnection(Action<byte[]> deliver)
internal LiteNetLibTransportConnection(Action<byte[]> deliver, Action? end = null)
{
_deliver = deliver ?? throw new ArgumentNullException(nameof(deliver));
_end = end;
Profile = CultNetTransportProfiles.CreateLiteNetLib("csharp-litenetlib-peer");
}
/// <summary>Answers a schema frame that did not decode with a <c>message_invalid</c> error.v1 naming its id when it holds one.</summary>
internal void AnswerUnreadableSchemaFrame(byte[] payload) =>
SendSchema(CultNetErrorV1Message.From(
CultNetErrorMessage.ForMessageInvalid("message", "the message could not be read"),
CultNetReadableMessageId.From(payload)));
/// <summary>
/// Ends the connection. A write that can be neither answered nor refused is answered by this goodbye: the peer sees
/// its session end and settles the write as unconfirmed (<c>session_ended</c>), never as silence.
/// </summary>
internal void End() => _end?.Invoke();
/// <summary>
/// Answers a schema frame that did not decode with a <c>message_invalid</c> error.v1 naming its id when it holds one;
/// when that answer cannot be sent the connection ends instead.
/// </summary>
internal void AnswerUnreadableSchemaFrame(byte[] payload)
{
try
{
SendSchema(CultNetErrorV1Message.From(
CultNetErrorMessage.ForMessageInvalid("message", "the message could not be read"),
CultNetReadableMessageId.From(payload)));
}
catch (Exception)
{
End();
}
}
private readonly object _writeFramingGate = new();
private bool _writeFramingSettled;