26 lines
1.1 KiB
C#
26 lines
1.1 KiB
C#
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<SendOutcome> SendAsync(EncodedPacket packet, CancellationToken cancellationToken = default);
|
|
ValueTask DisconnectAsync(int reason, string debug);
|
|
}
|
|
|
|
internal interface IServerIngress
|
|
{
|
|
Task<bool> AcceptConnectionAsync(IGameConnection connection, CancellationToken cancellationToken);
|
|
Task HandleMessageAsync(IGameConnection connection, ReadOnlyMemory<byte> 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");
|
|
}
|