using System.Net; namespace CommonwealthOnline.Server; internal enum SendOutcome { Sent, Dropped, Backpressure, NotConnected, TooLarge, Error } internal interface IGameConnection : IAsyncDisposable { string ConnectionKey { get; } string TransportName { get; } IPEndPoint RemoteEndpoint { get; } bool IsClosed { get; } ValueTask SendAsync(EncodedPacket packet, CancellationToken cancellationToken = default); ValueTask DisconnectAsync(int reason, string debug); } internal interface IServerIngress { Task AcceptConnectionAsync(IGameConnection connection, CancellationToken cancellationToken); Task HandleMessageAsync(IGameConnection connection, ReadOnlyMemory payload, CancellationToken cancellationToken); Task HandleConnectionClosedAsync(IGameConnection connection); Task HandleTransportRejectAsync(IGameConnection connection, string reason, bool warning = false); Task EndSessionForTransportAsync(IGameConnection connection, string code, string reason); void Log(string message, string level = "info"); }