Files
2025-11-04 14:12:47 -05:00

23 lines
669 B
C#

using System.Net;
namespace Server.Networking;
public interface IConnection : IAsyncDisposable
{
Guid Id { get; }
EndPoint? RemoteEndPoint { get; }
DateTime LastSeenUtc { get; }
// Send a raw payload (already framed/serialized by caller)
ValueTask SendAsync(ReadOnlyMemory<byte> payload, CancellationToken ct = default);
// Receive next **complete** message (length-prefixed by transport adapter)
ValueTask<ReadOnlyMemory<byte>?> ReceiveAsync(CancellationToken ct = default);
// For heartbeats/metrics
bool IsAlive { get; }
// Close with reason
ValueTask CloseAsync(string reason, CancellationToken ct = default);
}