2024-04-06 13:46:34 +02:00
|
|
|
using System.Net.Sockets;
|
|
|
|
|
2024-04-07 19:52:16 +02:00
|
|
|
namespace TanksServer.TickSteps;
|
2024-04-06 13:46:34 +02:00
|
|
|
|
2024-04-07 19:52:16 +02:00
|
|
|
internal sealed class SendToServicePointDisplay(
|
2024-04-07 13:02:49 +02:00
|
|
|
IOptions<ServicePointDisplayConfiguration> options,
|
|
|
|
PixelDrawer drawer
|
|
|
|
) : ITickStep, IDisposable
|
2024-04-06 13:46:34 +02:00
|
|
|
{
|
|
|
|
private readonly UdpClient _udpClient = new(options.Value.Hostname, options.Value.Port);
|
|
|
|
|
2024-04-07 13:02:49 +02:00
|
|
|
public Task TickAsync()
|
2024-04-06 13:46:34 +02:00
|
|
|
{
|
2024-04-07 13:02:49 +02:00
|
|
|
return _udpClient.SendAsync(drawer.LastFrame.Data).AsTask();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
_udpClient.Dispose();
|
2024-04-06 13:46:34 +02:00
|
|
|
}
|
|
|
|
}
|