servicepoint-tanks/TanksServer/Services/ServicePointDisplay.cs
2024-04-07 13:02:49 +02:00

29 lines
673 B
C#

using System.Net.Sockets;
using Microsoft.Extensions.Options;
namespace TanksServer.Services;
internal sealed class ServicePointDisplay(
IOptions<ServicePointDisplayConfiguration> options,
PixelDrawer drawer
) : ITickStep, IDisposable
{
private readonly UdpClient _udpClient = new(options.Value.Hostname, options.Value.Port);
public Task TickAsync()
{
return _udpClient.SendAsync(drawer.LastFrame.Data).AsTask();
}
public void Dispose()
{
_udpClient.Dispose();
}
}
internal sealed class ServicePointDisplayConfiguration
{
public string Hostname { get; set; } = string.Empty;
public int Port { get; set; }
}