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-01 19:04:24 +01:00
|
|
|
using Squirrowse.Client.Service;
|
2019-11-06 17:02:06 +01:00
|
|
|
using Squirrowse.Core.Models;
|
|
|
|
using Squirrowse.Core.Services;
|
2019-10-31 13:08:42 +01:00
|
|
|
|
|
|
|
namespace Squirrowse.Client
|
|
|
|
{
|
2019-11-06 11:49:39 +01:00
|
|
|
public class Worker : IHostedService
|
2019-10-31 13:08:42 +01:00
|
|
|
{
|
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-11-06 13:47:00 +01:00
|
|
|
private readonly ILogger<Worker> logger;
|
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-06 13:47:00 +01:00
|
|
|
_connectionManager = connectionManager;
|
2019-11-04 14:28:45 +01:00
|
|
|
this.camera = camera;
|
2019-10-31 13:08:42 +01:00
|
|
|
}
|
|
|
|
|
2019-11-06 11:49:39 +01:00
|
|
|
public async Task StartAsync(CancellationToken cancellationToken)
|
2019-10-31 13:08:42 +01:00
|
|
|
{
|
2019-11-07 11:52:27 +01:00
|
|
|
for (var i = 0; i < 100; i++) await _connectionManager.InitConnection(ConnectionType.Client);
|
2019-11-06 11:49:39 +01:00
|
|
|
}
|
2019-11-05 10:30:31 +01:00
|
|
|
|
2019-11-06 11:49:39 +01:00
|
|
|
public async Task StopAsync(CancellationToken cancellationToken)
|
|
|
|
{
|
|
|
|
await _connectionManager.Disconnect();
|
2019-10-31 13:08:42 +01:00
|
|
|
}
|
|
|
|
}
|
2019-11-04 09:29:37 +01:00
|
|
|
}
|