Codecleanup
This commit is contained in:
parent
0f05560c45
commit
e91a5143dd
@ -1,7 +1,3 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Squirrowse.Client.Service;
|
using Squirrowse.Client.Service;
|
||||||
@ -15,8 +11,9 @@ namespace Squirrowse.Client
|
|||||||
CreateHostBuilder(args).Build().Run();
|
CreateHostBuilder(args).Build().Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
public static IHostBuilder CreateHostBuilder(string[] args)
|
||||||
Host.CreateDefaultBuilder(args)
|
{
|
||||||
|
return Host.CreateDefaultBuilder(args)
|
||||||
.ConfigureServices((hostContext, services) =>
|
.ConfigureServices((hostContext, services) =>
|
||||||
{
|
{
|
||||||
services.AddHostedService<Worker>();
|
services.AddHostedService<Worker>();
|
||||||
@ -24,3 +21,4 @@ namespace Squirrowse.Client
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using OpenCvSharp;
|
using OpenCvSharp;
|
||||||
|
|
||||||
@ -10,7 +8,6 @@ namespace Squirrowse.Client.Service
|
|||||||
{
|
{
|
||||||
public VideoCapture GetCamera(int height = 480, int widght = 640, double fps = 15f, bool disposable = false)
|
public VideoCapture GetCamera(int height = 480, int widght = 640, double fps = 15f, bool disposable = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
var cam = new VideoCapture(CaptureDevice.Any);
|
var cam = new VideoCapture(CaptureDevice.Any);
|
||||||
cam.Fps = fps;
|
cam.Fps = fps;
|
||||||
cam.FrameHeight = height;
|
cam.FrameHeight = height;
|
||||||
|
@ -14,9 +14,11 @@ namespace Squirrowse.Client.Service
|
|||||||
.AddMessagePackProtocol()
|
.AddMessagePackProtocol()
|
||||||
.WithAutomaticReconnect()
|
.WithAutomaticReconnect()
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HubConnection Connect() => _connection;
|
public HubConnection Connect()
|
||||||
|
{
|
||||||
|
return _connection;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,14 +1,11 @@
|
|||||||
using OpenCvSharp;
|
using System.Threading.Tasks;
|
||||||
using System;
|
using OpenCvSharp;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Squirrowse.Client.Service
|
namespace Squirrowse.Client.Service
|
||||||
{
|
{
|
||||||
public interface ICameraService
|
public interface ICameraService
|
||||||
{
|
{
|
||||||
public VideoCapture GetCamera(int height = 480, int widght = 640, double fps = 15f, bool disposable = false);
|
VideoCapture GetCamera(int height = 480, int widght = 640, double fps = 15f, bool disposable = false);
|
||||||
public Task<Mat> GetFrame(VideoCapture video);
|
Task<Mat> GetFrame(VideoCapture video);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,6 +5,5 @@ namespace Squirrowse.Client.Service
|
|||||||
public interface IConnectionManager
|
public interface IConnectionManager
|
||||||
{
|
{
|
||||||
HubConnection Connect();
|
HubConnection Connect();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Squirrowse.Client.Service
|
namespace Squirrowse.Client.Service
|
||||||
@ -9,6 +7,5 @@ namespace Squirrowse.Client.Service
|
|||||||
{
|
{
|
||||||
Task SendStreamAsync(IAsyncEnumerable<byte[]> asb);
|
Task SendStreamAsync(IAsyncEnumerable<byte[]> asb);
|
||||||
Task SayHello();
|
Task SayHello();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,10 +1,8 @@
|
|||||||
using Microsoft.AspNetCore.SignalR.Client;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.SignalR.Client;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Squirrowse.Core.Models;
|
using Squirrowse.Core.Models;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Squirrowse.Client.Service
|
namespace Squirrowse.Client.Service
|
||||||
{
|
{
|
||||||
@ -13,6 +11,7 @@ namespace Squirrowse.Client.Service
|
|||||||
private readonly IConnectionManager connectionManager;
|
private readonly IConnectionManager connectionManager;
|
||||||
private readonly ILogger<StreamService> logger;
|
private readonly ILogger<StreamService> logger;
|
||||||
private readonly HubConnection session;
|
private readonly HubConnection session;
|
||||||
|
|
||||||
public StreamService(ILogger<StreamService> logger, IConnectionManager connectionManager)
|
public StreamService(ILogger<StreamService> logger, IConnectionManager connectionManager)
|
||||||
{
|
{
|
||||||
this.connectionManager = connectionManager;
|
this.connectionManager = connectionManager;
|
||||||
@ -22,24 +21,16 @@ namespace Squirrowse.Client.Service
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task SayHello()
|
public async Task SayHello()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
await session.SendAsync("AddToGroup", Groups.debug);
|
await session.SendAsync("AddToGroup", Groups.debug);
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task SendStreamAsync(IAsyncEnumerable<byte[]> asb)
|
public async Task SendStreamAsync(IAsyncEnumerable<byte[]> asb)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.LogInformation($"{nameof(SendStreamAsync)} Start stream");
|
logger.LogInformation($"{nameof(SendStreamAsync)} Start stream");
|
||||||
await session.SendAsync("UploadByteStream", asb, default);
|
await session.SendAsync("UploadByteStream", asb);
|
||||||
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Squirrowse.Core
|
namespace Squirrowse.Core
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
using System;
|
namespace Squirrowse.Core.Models
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Squirrowse.Core.Models
|
|
||||||
{
|
{
|
||||||
public enum Groups
|
public enum Groups
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using OpenCvSharp;
|
using OpenCvSharp;
|
||||||
|
|
||||||
namespace Squirrowse.Core.Services
|
namespace Squirrowse.Core.Services
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using Squirrowse.Core.Models;
|
using System.Collections.Generic;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Squirrowse.Core.Models;
|
||||||
|
|
||||||
namespace Squirrowse.Service.Hubs
|
namespace Squirrowse.Service.Hubs
|
||||||
{
|
{
|
||||||
@ -14,6 +13,5 @@ namespace Squirrowse.Service.Hubs
|
|||||||
Task ExecCommandOnAll(string command, object[] act); //gni
|
Task ExecCommandOnAll(string command, object[] act); //gni
|
||||||
Task AddToGroup(Groups group, string user = "");
|
Task AddToGroup(Groups group, string user = "");
|
||||||
Task RemoveFromGroup(Groups group, string user = "");
|
Task RemoveFromGroup(Groups group, string user = "");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,11 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Security.AccessControl;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using NLog;
|
|
||||||
using Squirrowse.Core.Models;
|
using Squirrowse.Core.Models;
|
||||||
|
|
||||||
namespace Squirrowse.Service.Hubs
|
namespace Squirrowse.Service.Hubs
|
||||||
@ -26,10 +23,11 @@ namespace Squirrowse.Service.Hubs
|
|||||||
|
|
||||||
public async Task AddToGroup(Groups group, string user = "")
|
public async Task AddToGroup(Groups group, string user = "")
|
||||||
{
|
{
|
||||||
string connectionId = string.IsNullOrWhiteSpace(user) ? Context.ConnectionId : user;
|
var connectionId = string.IsNullOrWhiteSpace(user) ? Context.ConnectionId : user;
|
||||||
await Groups.AddToGroupAsync(connectionId, group.ToString());
|
await Groups.AddToGroupAsync(connectionId, group.ToString());
|
||||||
logger.LogInformation($"{nameof(AddToGroup)}: {connectionId} joined to {group}");
|
logger.LogInformation($"{nameof(AddToGroup)}: {connectionId} joined to {group}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// USE ONLY FOR DEBUG
|
/// USE ONLY FOR DEBUG
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -42,8 +40,7 @@ namespace Squirrowse.Service.Hubs
|
|||||||
|
|
||||||
public async Task RemoveFromGroup(Groups group, string user = "")
|
public async Task RemoveFromGroup(Groups group, string user = "")
|
||||||
{
|
{
|
||||||
|
var connectionId = string.IsNullOrWhiteSpace(user) ? Context.ConnectionId : user;
|
||||||
string connectionId = string.IsNullOrWhiteSpace(user) ? Context.ConnectionId : user;
|
|
||||||
await Groups.RemoveFromGroupAsync(connectionId, group.ToString());
|
await Groups.RemoveFromGroupAsync(connectionId, group.ToString());
|
||||||
logger.LogInformation($"{nameof(AddToGroup)}: {connectionId} joined to {group}");
|
logger.LogInformation($"{nameof(AddToGroup)}: {connectionId} joined to {group}");
|
||||||
}
|
}
|
||||||
@ -71,6 +68,5 @@ namespace Squirrowse.Service.Hubs
|
|||||||
await Task.Delay(100); //leave some delay for debug purpose
|
await Task.Delay(100); //leave some delay for debug purpose
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,4 @@
|
|||||||
using System;
|
namespace Squirrowse.Service
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Squirrowse.Service
|
|
||||||
{
|
{
|
||||||
public interface IUserProvider
|
public interface IUserProvider
|
||||||
{
|
{
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NLog.Extensions.Logging;
|
using NLog.Extensions.Logging;
|
||||||
using NLog.Web;
|
using NLog.Web;
|
||||||
|
|
||||||
namespace Squirrowse.Service
|
namespace Squirrowse.Service
|
||||||
{
|
{
|
||||||
public class Program
|
public class Program
|
||||||
|
@ -24,7 +24,8 @@ namespace Squirrowse.Service
|
|||||||
services.AddControllers();
|
services.AddControllers();
|
||||||
services.AddMediatR(Assembly.GetAssembly(typeof(Startup)));
|
services.AddMediatR(Assembly.GetAssembly(typeof(Startup)));
|
||||||
services.AddSignalR()
|
services.AddSignalR()
|
||||||
.AddHubOptions<StreamHub>(opt => opt.MaximumReceiveMessageSize = 102400000)//~100mb per frame instead of 32kb default
|
.AddHubOptions<StreamHub
|
||||||
|
>(opt => opt.MaximumReceiveMessageSize = 102400000) //~100mb per frame instead of 32kb default
|
||||||
.AddMessagePackProtocol();
|
.AddMessagePackProtocol();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Squirrowse.Service
|
namespace Squirrowse.Service
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user