using Microsoft.AspNetCore.SignalR.Client; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; namespace Squirrowse.Client.Service { public class StreamService : IStreamService { private readonly IConnectionManager connectionManager; private readonly ILogger logger; public StreamService(ILogger logger, IConnectionManager connectionManager) { this.connectionManager = connectionManager; this.logger = logger; } public async Task SendStreamAsync(IAsyncEnumerable asb) { var con = connectionManager.Connect(); try { logger.LogInformation($"{nameof(SendStreamAsync)} Start stream"); await con.StartAsync(); await con.SendAsync("UploadByteStream", asb, default); } finally { logger.LogInformation($"{nameof(SendStreamAsync)} End stream"); await con.StopAsync(); } } } }