Codecleamup
This commit is contained in:
parent
b21b2c3678
commit
507e08ab19
@ -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< ICameraService, CameraService >(x=>new CameraService(new Camera()));
|
||||
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>();
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
@ -16,13 +17,13 @@ namespace Squirrowse.Client.Service
|
||||
{
|
||||
this.connectionManager = connectionManager;
|
||||
this.logger = logger;
|
||||
session.On("Start",StartStream);
|
||||
session.On("Stop",StopStream);
|
||||
session.On("Start", StartStream);
|
||||
session.On("Stop", StopStream);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenCvSharp;
|
||||
using OpenCvSharp;
|
||||
|
||||
namespace Squirrowse.Client.Service
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Squirrowse.Client.Service
|
||||
namespace Squirrowse.Client.Service
|
||||
{
|
||||
public interface ICameraFactory
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using OpenCvSharp;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user