Meum/Meum.Server/Program.cs
2025-05-09 16:32:35 +05:00

49 lines
1.3 KiB
C#

global using System;
global using System.Collections.Generic;
global using System.Threading;
global using System.Threading.Tasks;
global using Meum.Core;
using DTLib.Console;
using DTLib.Demystifier;
using DTLib.Filesystem;
using DTLib.Logging;
namespace Meum.Server;
static class Program
{
static readonly IOPath config_path = "Meum.Server.config.json";
static async Task Main(string[] args)
{
try
{
var config = ServerConfig.LoadOrCreate(config_path);
var logger = new ConsoleLogger();
Functions.InitMsQuic(logger);
var server = new Server(config, logger);
await server.ListenAsync();
while (true)
{
try
{
var conn = await server.AcceptConnectionAsync();
}
catch (Exception ex)
{
logger.LogError("Main", ex.ToStringDemystified());
}
}
}
catch (Exception ex)
{
ColoredConsole.WriteLine(ex.ToStringDemystified(), ConsoleColor.Red);
}
finally
{
Console.ResetColor();
}
}
}