42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.SignalR.Client;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace squirrowse.client
|
|
{
|
|
public class Worker : IHostedService
|
|
{
|
|
private readonly ILogger<Worker> logger;
|
|
private readonly IConnectionManager _connectionManager;
|
|
private Connection con =new Connection();
|
|
public Worker(ILogger<Worker> logger, IConnectionManager connectionManager)
|
|
{
|
|
this.logger = logger;
|
|
_connectionManager = connectionManager;
|
|
|
|
}
|
|
|
|
public async Task StartAsync(CancellationToken cancellationToken)
|
|
{
|
|
await _connectionManager.InitConnection();
|
|
|
|
//var d = _connectionManager.GetConnection();
|
|
if (_connectionManager.IsConnected())
|
|
{
|
|
var d =await _connectionManager.GetConnection();
|
|
await d.SendAsync("UploadStream", con.clientStreamData());
|
|
}
|
|
}
|
|
|
|
public async Task StopAsync(CancellationToken cancellationToken)
|
|
{
|
|
await _connectionManager.Disconnect();
|
|
}
|
|
}
|
|
}
|