diff --git a/Capy64/Assets/default.json b/Capy64/Assets/default.json new file mode 100644 index 0000000..f5d72f9 --- /dev/null +++ b/Capy64/Assets/default.json @@ -0,0 +1,10 @@ +{ + + "HTTP": { + "Blacklist": [], + "WebSockets": { + "Enable": true, + "MaxActiveConnections": 5 + } + } +} diff --git a/Capy64/Capy64.csproj b/Capy64/Capy64.csproj index e0e3a05..cbbc1fb 100644 --- a/Capy64/Capy64.csproj +++ b/Capy64/Capy64.csproj @@ -12,6 +12,12 @@ true + + + + + PreserveNewest + PreserveNewest diff --git a/Capy64/Configuration/WebSockets.cs b/Capy64/Configuration/WebSockets.cs new file mode 100644 index 0000000..d2adde8 --- /dev/null +++ b/Capy64/Configuration/WebSockets.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace Capy64.Configuration; + +class WebSockets +{ + public bool Enable { get; set; } = true; + public int MaxActiveConnections { get; set; } = 5; +} diff --git a/Capy64/Program.cs b/Capy64/Program.cs index 02ca9f5..a1164d7 100644 --- a/Capy64/Program.cs +++ b/Capy64/Program.cs @@ -1,10 +1,23 @@ using Capy64; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using System; +using System.IO; using var game = new Capy64.Capy64(); using IHost host = Host.CreateDefaultBuilder(args) + .ConfigureAppConfiguration((context, c) => + { + var settingsPath = Path.Combine(Capy64.Capy64.AppDataPath, "settings.json"); + if (!File.Exists(settingsPath)) + { + File.Copy("Assets/default.json", settingsPath); + } + + c.AddJsonFile("Assets/default.json", false); + c.AddJsonFile(settingsPath, false); + }) .ConfigureServices((hostContext, services) => { services.AddSingleton(game);