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