Elisa/Elisa.GameServer/GameServer.cs

56 lines
2.1 KiB
C#

using Elisa.Common.Data;
using Elisa.GameServer.Commands;
using Elisa.GameServer.Services;
using Serilog;
using System.Diagnostics;
using System.Reflection;
using System.Text.Encodings.Web;
namespace Elisa.GameServer;
public static class GameServer
{
public static string ClientVersion = 30400.ToString();
public static string DataVersion = "4e7d9f82634fd8c557600524b55c8efe";
public static string ABVersion = 2024052719.ToString();
public static void Main(string[] args)
{
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.Host.UseSerilog((context, configuration) => configuration.ReadFrom.Configuration(context.Configuration));
builder.Services.AddHttpClient();
builder.Services.AddControllers()
.AddJsonOptions(options => options.JsonSerializerOptions.Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
//builder.Services.AddHostedService(provider => new ProxyBackgroundService("127.0.0.1"));
WebApplication app = builder.Build();
app.UseSerilogRequestLogging();
app.UseAuthorization();
app.MapControllers();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
Log.Information($"Version {Assembly.GetEntryAssembly()?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion}");
Log.Information($"Client Version: {ClientVersion}");
Log.Information($"Data Version: {DataVersion}");
Log.Information($"AB Version: {ABVersion}");
Log.Information($"Starting {Assembly.GetEntryAssembly()?.GetName().Name.Split('.')[0]}...");
Stopwatch stopwatch = Stopwatch.StartNew();
{
CommandHandlerFactory.RegisterCommands(Assembly.GetExecutingAssembly());
Table.Load();
}
stopwatch.Stop();
Log.Information($"Done! Loaded in {stopwatch.ElapsedMilliseconds}ms");
app.Run();
}
}