Add C# dedicated server replacement

This commit is contained in:
Nomads_Reach
2026-08-16 02:23:04 -04:00
parent 0024436ce8
commit ddadf87423
17 changed files with 3516 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
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");
}