servicepoint-tanks/TanksServer/Services/ServicePointDisplay.cs

29 lines
673 B
C#
Raw Normal View History

using System.Net.Sockets;
using Microsoft.Extensions.Options;
2024-04-07 11:19:14 +02:00
namespace TanksServer.Services;
2024-04-07 13:02:49 +02:00
internal sealed class ServicePointDisplay(
IOptions<ServicePointDisplayConfiguration> options,
PixelDrawer drawer
) : ITickStep, IDisposable
{
private readonly UdpClient _udpClient = new(options.Value.Hostname, options.Value.Port);
2024-04-07 13:02:49 +02:00
public Task TickAsync()
{
2024-04-07 13:02:49 +02:00
return _udpClient.SendAsync(drawer.LastFrame.Data).AsTask();
}
public void Dispose()
{
_udpClient.Dispose();
}
}
2024-04-06 20:32:54 +02:00
2024-04-07 11:19:14 +02:00
internal sealed class ServicePointDisplayConfiguration
2024-04-06 20:32:54 +02:00
{
public string Hostname { get; set; } = string.Empty;
public int Port { get; set; }
}