test run works
This commit is contained in:
@@ -12,6 +12,7 @@ public class PrinterDiscoveryBackgroundTask
|
||||
private readonly IDiscoveryService _discoveryService;
|
||||
private readonly IDiscoveredPrintersReceiver _receiver;
|
||||
private readonly ILogger _logger;
|
||||
private readonly PrintServer _printServer;
|
||||
private readonly TimeSpan _interval;
|
||||
private readonly TimeSpan _discoveryTimeout;
|
||||
|
||||
@@ -21,11 +22,13 @@ public class PrinterDiscoveryBackgroundTask
|
||||
public PrinterDiscoveryBackgroundTask(
|
||||
IDiscoveryService discoveryService,
|
||||
IDiscoveredPrintersReceiver receiver,
|
||||
ILogger logger)
|
||||
ILogger logger,
|
||||
PrintServer printServer)
|
||||
{
|
||||
_discoveryService = discoveryService;
|
||||
_receiver = receiver;
|
||||
_logger = logger;
|
||||
_printServer = printServer;
|
||||
_interval = TimeSpan.FromSeconds(30);
|
||||
_discoveryTimeout = TimeSpan.FromSeconds(3);
|
||||
}
|
||||
@@ -67,13 +70,14 @@ public class PrinterDiscoveryBackgroundTask
|
||||
try
|
||||
{
|
||||
var printers = await _discoveryService.DiscoverPrintersAsync(_discoveryTimeout);
|
||||
printers.Add(new DiscoveredPrinter()
|
||||
{
|
||||
IPAddress = "127.0.0.1",
|
||||
ModelName = "TM-T30III",
|
||||
});
|
||||
|
||||
var currentIps = printers.Select(p => p.IPAddress).ToHashSet();
|
||||
|
||||
foreach (string currentIp in currentIps)
|
||||
{
|
||||
_printServer.RegisterPrinter(currentIp);
|
||||
}
|
||||
|
||||
if (HasConfigurationChanged(currentIps))
|
||||
{
|
||||
_logger.LogInformation("Discovered printer configuration changed: {Count} printer(s)", printers.Count);
|
||||
|
||||
Reference in New Issue
Block a user