Squirrowse/Squirrowse.Client/Service/ActionDispatcher.cs
danielgrabowski 507e08ab19 Codecleamup
2019-11-06 13:47:00 +01:00

47 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR.Client;
using Microsoft.Extensions.Logging;
using Squirrowse.Core.Models;
namespace Squirrowse.Client.Service
{
public class ActionDispatcher : IActionDispatcher
{
private readonly IConnectionManager connectionManager;
private readonly ILogger<ActionDispatcher> logger;
private readonly HubConnection session;
public ActionDispatcher(ILogger<ActionDispatcher> logger, IConnectionManager connectionManager)
{
this.connectionManager = connectionManager;
this.logger = logger;
session.On("Start", StartStream);
session.On("Stop", StopStream);
}
public Task StopStream()
{
throw new NotImplementedException();
}
public async Task SayHello()
{
await session.SendAsync("AddToGroup", Groups.debug);
}
public async Task SendStreamAsync(IAsyncEnumerable<byte[]> asb)
{
logger.LogInformation($"{nameof(SendStreamAsync)} Start stream");
await session.SendAsync("UploadByteStream", asb);
logger.LogInformation($"{nameof(SendStreamAsync)} End stream");
}
public Task StartStream()
{
throw new NotImplementedException();
}
}
}