mirror of
https://github.com/raphaeIl/Novaria.git
synced 2025-12-13 06:54:48 +01:00
add diff files for auto updating client, readme for installation and running tutorial
This commit is contained in:
55
Novaria.GameServer/GameServer.cs
Normal file
55
Novaria.GameServer/GameServer.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using Serilog;
|
||||
|
||||
using Novaria.GameServer.Controllers.Api.ProtocolHandlers;
|
||||
|
||||
namespace Novaria.GameServer
|
||||
{
|
||||
public class GameServer
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Log.Information("Starting SDK Server...");
|
||||
try
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.Configure<KestrelServerOptions>(op =>
|
||||
op.AllowSynchronousIO = true
|
||||
);
|
||||
builder.Host.UseSerilog();
|
||||
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddProtocolHandlerFactory();
|
||||
builder.Services.AddControllers().AddApplicationPart(Assembly.GetAssembly(typeof(GameServer)));
|
||||
|
||||
// Add all Handler Groups
|
||||
var handlerGroups = Assembly.GetAssembly(typeof(ProtocolHandlerFactory))
|
||||
.GetTypes()
|
||||
.Where(t => t.IsSubclassOf(typeof(ProtocolHandlerBase)));
|
||||
|
||||
foreach (var handlerGroup in handlerGroups)
|
||||
{
|
||||
builder.Services.AddProtocolHandlerGroupByType(handlerGroup);
|
||||
}
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.UseAuthorization();
|
||||
app.UseSerilogRequestLogging();
|
||||
|
||||
app.MapControllers();
|
||||
app.Run();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Fatal(ex, "An unhandled exception occurred during runtime");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user