2019-11-04 09:29:37 +01:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.AspNetCore.SignalR.Client;
|
2019-11-01 19:04:24 +01:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2019-11-02 21:06:44 +01:00
|
|
|
|
using Squirrowse.Core.Models;
|
2019-11-01 19:04:24 +01:00
|
|
|
|
|
|
|
|
|
namespace Squirrowse.Client.Service
|
|
|
|
|
{
|
2019-11-05 17:00:36 +01:00
|
|
|
|
public class ActionDispatcher : IActionDispatcher
|
2019-11-01 19:04:24 +01:00
|
|
|
|
{
|
|
|
|
|
private readonly IConnectionManager connectionManager;
|
2019-11-05 17:00:36 +01:00
|
|
|
|
private readonly ILogger<ActionDispatcher> logger;
|
2019-11-02 21:06:44 +01:00
|
|
|
|
private readonly HubConnection session;
|
2019-11-05 17:00:36 +01:00
|
|
|
|
|
|
|
|
|
public ActionDispatcher(ILogger<ActionDispatcher> logger, IConnectionManager connectionManager)
|
2019-11-01 19:04:24 +01:00
|
|
|
|
{
|
|
|
|
|
this.connectionManager = connectionManager;
|
|
|
|
|
this.logger = logger;
|
2019-11-05 17:00:36 +01:00
|
|
|
|
session.On("Start",StartStream);
|
|
|
|
|
session.On("Stop",StopStream);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task StopStream()
|
|
|
|
|
{
|
|
|
|
|
throw new System.NotImplementedException();
|
2019-11-02 21:06:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task SayHello()
|
|
|
|
|
{
|
2019-11-04 09:29:37 +01:00
|
|
|
|
await session.SendAsync("AddToGroup", Groups.debug);
|
2019-11-01 19:04:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task SendStreamAsync(IAsyncEnumerable<byte[]> asb)
|
|
|
|
|
{
|
2019-11-05 10:30:31 +01:00
|
|
|
|
logger.LogInformation($"{nameof(SendStreamAsync)} Start stream");
|
|
|
|
|
await session.SendAsync("UploadByteStream", asb);
|
|
|
|
|
|
|
|
|
|
logger.LogInformation($"{nameof(SendStreamAsync)} End stream");
|
2019-11-01 19:04:24 +01:00
|
|
|
|
}
|
2019-11-05 17:00:36 +01:00
|
|
|
|
|
|
|
|
|
public Task StartStream()
|
|
|
|
|
{
|
|
|
|
|
throw new System.NotImplementedException();
|
|
|
|
|
}
|
2019-11-01 19:04:24 +01:00
|
|
|
|
}
|
2019-11-04 09:29:37 +01:00
|
|
|
|
}
|