Supercell.GUT/Supercell.GUT.Server/Program.cs

50 lines
2 KiB
C#
Raw Normal View History

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Supercell.GUT.Logic.Message;
using Supercell.GUT.Server.Database;
using Supercell.GUT.Server.Database.Options;
using Supercell.GUT.Server.Debugging;
using Supercell.GUT.Server.Document;
using Supercell.GUT.Server.Network;
using Supercell.GUT.Server.Network.Connection;
using Supercell.GUT.Server.Network.Options;
using Supercell.GUT.Server.Network.Tcp;
using Supercell.GUT.Server.Protocol;
using Supercell.GUT.Server.Protocol.Extensions;
using Supercell.GUT.Titan.Logic.Debug;
using Supercell.GUT.Titan.Logic.Message;
namespace Supercell.GUT.Server;
internal static class Program
{
private const string GatewayOptionsSection = "Gateway";
private const string DatabaseOptionsSection = "Database";
private static async Task Main(string[] args)
{
Console.Title = "Battle Buddies Server Emulator";
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
builder.Services.Configure<GatewayOptions>(builder.Configuration.GetRequiredSection(GatewayOptionsSection));
builder.Services.Configure<DatabaseOptions>(builder.Configuration.GetRequiredSection(DatabaseOptionsSection));
builder.Services.AddHandlers();
builder.Services.AddSingleton<IDebuggerListener, ServerDebuggerListener>();
builder.Services.AddSingleton<IServerGateway, TcpGateway>();
builder.Services.AddSingleton<IGatewayEventListener, ClientConnectionManager>();
builder.Services.AddScoped<ClientConnection>();
builder.Services.AddScoped<IConnectionListener, Messaging>();
builder.Services.AddSingleton<LogicMessageFactory, GUTMessageFactory>();
builder.Services.AddScoped<MessageManager>();
builder.Services.AddScoped<DocumentManager>();
builder.Services.AddSingleton<DatabaseManager>();
builder.Services.AddHostedService<GUTServer>();
await builder.Build().RunAsync();
}
}