move more websocket logic into base classes

This commit is contained in:
Vinzenz Schroeter 2024-04-21 23:21:15 +02:00
parent 57c0d229f1
commit fb675e59ff
7 changed files with 89 additions and 123 deletions

View file

@ -2,10 +2,10 @@ using Microsoft.Extensions.Hosting;
namespace TanksServer.Interactivity;
internal class WebsocketServer<T>(
internal abstract class WebsocketServer<T>(
ILogger logger
) : IHostedLifecycleService, IDisposable
where T : IWebsocketServerConnection
where T : WebsocketServerConnection
{
private readonly SemaphoreSlim _mutex = new(1, 1);
private bool _closing;
@ -56,7 +56,7 @@ internal class WebsocketServer<T>(
protected async Task HandleClientAsync(T connection)
{
await AddConnection(connection);
await connection.Done;
await connection.ReceiveAsync();
await RemoveConnection(connection);
}