diff --git a/Squirrowse.Client/Program.cs b/Squirrowse.Client/Program.cs index 88acb1c..a3d978e 100644 --- a/Squirrowse.Client/Program.cs +++ b/Squirrowse.Client/Program.cs @@ -1,12 +1,24 @@ -using System; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Squirrowse.Client { - class Program + public class Program { - static void Main(string[] args) + public static void Main(string[] args) { - Console.WriteLine("Hello World!"); + CreateHostBuilder(args).Build().Run(); } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureServices((hostContext, services) => + { + services.AddHostedService(); + }); } } diff --git a/Squirrowse.Client/Properties/launchSettings.json b/Squirrowse.Client/Properties/launchSettings.json new file mode 100644 index 0000000..4858d8e --- /dev/null +++ b/Squirrowse.Client/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "Squirrowse.Client": { + "commandName": "Project", + "environmentVariables": { + "DOTNET_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Squirrowse.Client/Squirrowse.Client.csproj b/Squirrowse.Client/Squirrowse.Client.csproj index a34d51e..81c0779 100644 --- a/Squirrowse.Client/Squirrowse.Client.csproj +++ b/Squirrowse.Client/Squirrowse.Client.csproj @@ -1,15 +1,14 @@ - + - Exe netcoreapp3.0 + dotnet-Squirrowse.Client-D6805387-040A-46DF-9DAE-926B46C981A6 - + + - - diff --git a/Squirrowse.Client/Worker.cs b/Squirrowse.Client/Worker.cs new file mode 100644 index 0000000..33a59d9 --- /dev/null +++ b/Squirrowse.Client/Worker.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace Squirrowse.Client +{ + public class Worker : BackgroundService + { + private readonly ILogger _logger; + + public Worker(ILogger logger) + { + _logger = logger; + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + while (!stoppingToken.IsCancellationRequested) + { + _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); + await Task.Delay(1000, stoppingToken); + } + } + } +} diff --git a/Squirrowse.Client/appsettings.Development.json b/Squirrowse.Client/appsettings.Development.json new file mode 100644 index 0000000..e203e94 --- /dev/null +++ b/Squirrowse.Client/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/Squirrowse.Client/appsettings.json b/Squirrowse.Client/appsettings.json new file mode 100644 index 0000000..8983e0f --- /dev/null +++ b/Squirrowse.Client/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/Squirrowse.Service/Squirrowse.Service.csproj b/Squirrowse.Service/Squirrowse.Service.csproj index e0927c4..5d22ada 100644 --- a/Squirrowse.Service/Squirrowse.Service.csproj +++ b/Squirrowse.Service/Squirrowse.Service.csproj @@ -9,6 +9,8 @@ + + diff --git a/Squirrowse.Service/Startup.cs b/Squirrowse.Service/Startup.cs index 2f12361..d11e0be 100644 --- a/Squirrowse.Service/Startup.cs +++ b/Squirrowse.Service/Startup.cs @@ -1,3 +1,5 @@ +using System.Reflection; +using MediatR; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; @@ -20,6 +22,7 @@ namespace Squirrowse.Service public void ConfigureServices(IServiceCollection services) { services.AddControllers(); + services.AddMediatR(Assembly.GetAssembly(typeof(Startup))); services.AddSignalR() .AddHubOptions(opt => opt.MaximumReceiveMessageSize = 102400000)//~100mb per frame instead of 32kb default .AddMessagePackProtocol(); diff --git a/Squirrowse.sln b/Squirrowse.sln index ad1eacc..0841d41 100644 --- a/Squirrowse.sln +++ b/Squirrowse.sln @@ -5,7 +5,7 @@ VisualStudioVersion = 16.0.29411.108 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squirrowse.Service", "Squirrowse.Service\Squirrowse.Service.csproj", "{8C085621-BAAA-4E96-B027-561BC18751EE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squirrowse.Client", "Squirrowse.Client\Squirrowse.Client.csproj", "{A523B8A9-958B-45EC-B5E4-54FDF08C1C5D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squirrowse.Client", "Squirrowse.Client\Squirrowse.Client.csproj", "{558A5917-6AD3-4C40-ACA1-EE3B8B8927C8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -17,10 +17,10 @@ Global {8C085621-BAAA-4E96-B027-561BC18751EE}.Debug|Any CPU.Build.0 = Debug|Any CPU {8C085621-BAAA-4E96-B027-561BC18751EE}.Release|Any CPU.ActiveCfg = Release|Any CPU {8C085621-BAAA-4E96-B027-561BC18751EE}.Release|Any CPU.Build.0 = Release|Any CPU - {A523B8A9-958B-45EC-B5E4-54FDF08C1C5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A523B8A9-958B-45EC-B5E4-54FDF08C1C5D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A523B8A9-958B-45EC-B5E4-54FDF08C1C5D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A523B8A9-958B-45EC-B5E4-54FDF08C1C5D}.Release|Any CPU.Build.0 = Release|Any CPU + {558A5917-6AD3-4C40-ACA1-EE3B8B8927C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {558A5917-6AD3-4C40-ACA1-EE3B8B8927C8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {558A5917-6AD3-4C40-ACA1-EE3B8B8927C8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {558A5917-6AD3-4C40-ACA1-EE3B8B8927C8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE