remove guid, reduce latency (gets stuck sometimes tho)

This commit is contained in:
Vinzenz Schroeter 2024-04-28 12:53:18 +02:00
parent 6bc6a039bd
commit 7044ffda79
19 changed files with 291 additions and 251 deletions

View file

@ -6,20 +6,16 @@ namespace TanksServer.Interactivity;
internal sealed class ClientScreenServer(
ILogger<ClientScreenServer> logger,
ILoggerFactory loggerFactory,
IOptions<HostConfiguration> hostConfig
ILoggerFactory loggerFactory
) : WebsocketServer<ClientScreenServerConnection>(logger), IFrameConsumer
{
private readonly TimeSpan _minFrameTime = TimeSpan.FromMilliseconds(hostConfig.Value.ClientDisplayMinFrameTimeMs);
public Task HandleClientAsync(WebSocket socket, Guid? playerGuid)
public Task HandleClientAsync(WebSocket socket, string? player)
=> base.HandleClientAsync(new(
socket,
loggerFactory.CreateLogger<ClientScreenServerConnection>(),
_minFrameTime,
playerGuid
player
));
public Task OnFrameDoneAsync(GamePixelGrid gamePixelGrid, PixelGrid observerPixels)
=> ParallelForEachConnectionAsync(c => c.SendAsync(observerPixels, gamePixelGrid));
=> ParallelForEachConnectionAsync(c => c.OnGameTickAsync(observerPixels, gamePixelGrid).AsTask());
}