2019-10-31 13:08:42 +01:00
|
|
|
using System;
|
2019-11-05 17:00:36 +01:00
|
|
|
using System.Drawing;
|
2019-10-31 13:08:42 +01:00
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
using Microsoft.Extensions.Logging;
|
2019-11-05 10:30:31 +01:00
|
|
|
using OpenCvSharp;
|
2019-11-01 19:04:24 +01:00
|
|
|
using Squirrowse.Client.Service;
|
2019-10-31 13:08:42 +01:00
|
|
|
|
|
|
|
namespace Squirrowse.Client
|
|
|
|
{
|
|
|
|
public class Worker : BackgroundService
|
|
|
|
{
|
2019-11-04 14:28:45 +01:00
|
|
|
private readonly ILogger<Worker> logger;
|
2019-11-05 17:00:36 +01:00
|
|
|
private readonly IConnectionManager _connectionManager;
|
2019-11-04 14:28:45 +01:00
|
|
|
private readonly ICameraService camera;
|
2019-10-31 13:08:42 +01:00
|
|
|
|
2019-11-05 17:00:36 +01:00
|
|
|
public Worker(ILogger<Worker> logger, IConnectionManager connectionManager, ICameraService camera)
|
2019-10-31 13:08:42 +01:00
|
|
|
{
|
2019-11-04 14:28:45 +01:00
|
|
|
this.logger = logger;
|
2019-11-05 17:00:36 +01:00
|
|
|
this._connectionManager = connectionManager;
|
2019-11-04 14:28:45 +01:00
|
|
|
this.camera = camera;
|
2019-10-31 13:08:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
|
|
|
{
|
2019-11-05 10:30:31 +01:00
|
|
|
|
|
|
|
while (!stoppingToken.IsCancellationRequested)
|
|
|
|
{
|
2019-11-04 14:28:45 +01:00
|
|
|
logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
|
2019-11-04 09:29:37 +01:00
|
|
|
|
2019-11-05 17:00:36 +01:00
|
|
|
await _connectionManager.GetConnection();
|
|
|
|
//await _connectionManager.SendStreamAsync(camera.GetFramesAsyncEnumerator());
|
2019-11-04 14:28:45 +01:00
|
|
|
|
2019-11-05 17:00:36 +01:00
|
|
|
// await Task.Delay(50, stoppingToken);
|
2019-11-05 10:30:31 +01:00
|
|
|
}
|
2019-10-31 13:08:42 +01:00
|
|
|
}
|
|
|
|
}
|
2019-11-04 09:29:37 +01:00
|
|
|
}
|