using Microsoft.AspNetCore.SignalR.Client; using Microsoft.Extensions.Logging; using Squirrowse.Core.Models; 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; private readonly HubConnection session; public StreamService(ILogger logger, IConnectionManager connectionManager) { this.connectionManager = connectionManager; this.logger = logger; session = connectionManager.Connect(); session.StartAsync().ConfigureAwait(false); } public async Task SayHello() { try { await session.SendAsync("AddToGroup",Groups.debug); } finally { } } public async Task SendStreamAsync(IAsyncEnumerable asb) { try { logger.LogInformation($"{nameof(SendStreamAsync)} Start stream"); await session.SendAsync("UploadByteStream", asb, default); } finally { logger.LogInformation($"{nameof(SendStreamAsync)} End stream"); } } } }