Codecleamup

This commit is contained in:
danielgrabowski 2019-11-06 13:47:00 +01:00
parent b21b2c3678
commit 507e08ab19
13 changed files with 43 additions and 63 deletions

View File

@ -17,10 +17,10 @@ namespace Squirrowse.Client
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<Worker>();
services.AddSingleton<IConnectionManager>(x=> new ConnectionManager("http://localhost", 5000)); //keep as transient for now
services.AddSingleton<IConnectionManager>(x =>
new ConnectionManager("http://localhost", 5000)); //keep as transient for now
services.AddSingleton<ICameraService, CameraService>(x => new CameraService(new Camera()));
services.AddSingleton<IActionDispatcher, ActionDispatcher>();
});
}
}

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR.Client;
using Microsoft.Extensions.Logging;
@ -22,7 +23,7 @@ namespace Squirrowse.Client.Service
public Task StopStream()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
public async Task SayHello()
@ -40,7 +41,7 @@ namespace Squirrowse.Client.Service
public Task StartStream()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
}
}

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenCvSharp;
using OpenCvSharp;
namespace Squirrowse.Client.Service
{

View File

@ -17,25 +17,18 @@ namespace Squirrowse.Client.Service
.AddMessagePackProtocol()
.WithAutomaticReconnect()
.Build();
}
public async Task<HubConnection> GetConnection()
{
if (Connected)
{
return _connection;
}
if (Connected) return _connection;
throw new Exception();
}
public async Task InitConnection()
{
if (_connection.State == HubConnectionState.Connected)
{
return;
}
if (_connection.State == HubConnectionState.Connected) return;
await _connection.StartAsync();
await RegisterOnHub();
Connected = true;

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Squirrowse.Client.Service
namespace Squirrowse.Client.Service
{
public interface ICameraFactory
{

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading.Tasks;
using OpenCvSharp;

View File

@ -1,24 +1,21 @@
using System;
using System.Drawing;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using OpenCvSharp;
using Squirrowse.Client.Service;
namespace Squirrowse.Client
{
public class Worker : IHostedService
{
private readonly ILogger<Worker> logger;
private readonly IConnectionManager _connectionManager;
private readonly ICameraService camera;
private readonly ILogger<Worker> logger;
public Worker(ILogger<Worker> logger, IConnectionManager connectionManager, ICameraService camera)
{
this.logger = logger;
this._connectionManager = connectionManager;
_connectionManager = connectionManager;
this.camera = camera;
}

View File

@ -2,13 +2,13 @@
{
public class User
{
public string ConnectionId { get; set; }
public string AgentName { get; set; }
public User(string connectionId, string agentName)
{
ConnectionId = connectionId;
AgentName = agentName;
}
public string ConnectionId { get; set; }
public string AgentName { get; set; }
}
}

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Threading.Tasks;
namespace Squirrowse.Service.Hubs
{
@ -11,6 +8,5 @@ namespace Squirrowse.Service.Hubs
Task RemoveUserbyConnectionId(string connectionId);
Task RemoveUserByUserName(string agentName);
bool CheckUser(string agentName);
}
}

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
@ -13,6 +12,8 @@ namespace Squirrowse.Service.Hubs
{
private readonly ILogger<StreamHub> logger;
private readonly IStreamManager manager;
public Window okno = new Window("test");
public StreamHub(ILogger<StreamHub> logger, IStreamManager manager)
{
this.logger = logger;
@ -62,10 +63,9 @@ namespace Squirrowse.Service.Hubs
await client.SendAsync("Stop");
}
public Window okno = new Window("test");
public async Task UploadByteStream(IAsyncEnumerable<byte[]> stream)
{
await foreach (var frame in stream)
{
using var imgbuffer = frame.ConvertByteToMat();

View File

@ -25,6 +25,7 @@ namespace Squirrowse.Service
services.AddControllers();
services.AddMediatR(Assembly.GetAssembly(typeof(Startup)));
services.AddTransient<IStreamHub, StreamHub>();
services.AddTransient<IStreamManager, StreamManager>();
services.AddCoreModule();
services.AddSignalR()
.AddHubOptions<StreamHub