make big display toggleable
This commit is contained in:
parent
a9aaf899a2
commit
dc9ad21a3d
1 changed files with 119 additions and 46 deletions
|
|
@ -1,21 +1,25 @@
|
|||
using System.Net.Sockets;
|
||||
using TanksServer.Models;
|
||||
using TanksServer.Services;
|
||||
|
||||
namespace TanksServer.TickSteps;
|
||||
|
||||
internal sealed class SendToServicePointDisplay(
|
||||
IOptions<ServicePointDisplayConfiguration> options,
|
||||
PixelDrawer drawer
|
||||
IOptions<ServicePointDisplayConfiguration> options,
|
||||
LastFinishedFrameProvider lastFinishedFrameProvider
|
||||
) : ITickStep, IDisposable
|
||||
{
|
||||
private readonly UdpClient _udpClient = new(options.Value.Hostname, options.Value.Port);
|
||||
private readonly UdpClient? _udpClient = options.Value.Enable
|
||||
? new(options.Value.Hostname, options.Value.Port)
|
||||
: null;
|
||||
|
||||
public Task TickAsync()
|
||||
{
|
||||
return _udpClient.SendAsync(drawer.LastFrame.Data).AsTask();
|
||||
return _udpClient?.SendAsync(lastFinishedFrameProvider.LastFrame.Data).AsTask() ?? Task.CompletedTask;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_udpClient.Dispose();
|
||||
_udpClient?.Dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue