2023-09-23 11:11:07 +00:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.Configuration.Yaml;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Tiger.Communication.Messages;
|
2023-10-06 16:12:35 +00:00
|
|
|
|
using Tiger.Game.Catalogue;
|
2023-10-06 18:46:50 +00:00
|
|
|
|
using Tiger.Game.Figuredata;
|
2023-09-23 11:11:07 +00:00
|
|
|
|
using Tiger.Game.Habbos;
|
|
|
|
|
using Tiger.Game.Settings;
|
|
|
|
|
using Tiger.Networking.Game;
|
|
|
|
|
using Tiger.Networking.Game.Sessions;
|
|
|
|
|
using Tiger.Storage;
|
|
|
|
|
using Tiger.Utils;
|
|
|
|
|
|
|
|
|
|
var quitEvent = new ManualResetEvent(false);
|
|
|
|
|
|
|
|
|
|
Console.CancelKeyPress += (sender, e) =>
|
|
|
|
|
{
|
|
|
|
|
quitEvent.Set();
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var configuration = new ConfigurationBuilder()
|
|
|
|
|
.SetBasePath(Directory.GetCurrentDirectory())
|
|
|
|
|
.AddYamlFile("appsettings.yaml")
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var collection = new ServiceCollection();
|
|
|
|
|
collection.AddLogging(builder => builder.AddConsole());
|
|
|
|
|
collection.AddSingleton<IConfiguration>(configuration);
|
|
|
|
|
collection.AddSingleton<IWebSocketServer, WebSocketServer>();
|
|
|
|
|
collection.AddSingleton<IGameSessionManager, GameSessionManager>();
|
|
|
|
|
collection.AddSingleton<IMessageHandler, MessageHandler>();
|
2023-09-23 12:20:45 +00:00
|
|
|
|
collection.AddSingleton<INhSessionFactory, NhSessionFactory>();
|
|
|
|
|
collection.AddScoped(serviceProvider => serviceProvider.GetRequiredService<INhSessionFactory>().OpenSession());
|
|
|
|
|
collection.AddScoped(typeof(IRepository<>), typeof(Repository<>));
|
|
|
|
|
collection.AddSingleton<ISettingManager, SettingManager>();
|
2023-10-06 16:12:35 +00:00
|
|
|
|
collection.AddSingleton<ICatalogueManager, CatalogueManager>();
|
2023-10-06 18:46:50 +00:00
|
|
|
|
collection.AddSingleton<IFigureDataManager, FiguredataManager>();
|
2023-09-23 11:11:07 +00:00
|
|
|
|
collection.RegisterMessageEvents();
|
|
|
|
|
|
|
|
|
|
var provider = collection.BuildServiceProvider();
|
|
|
|
|
|
2023-09-23 12:20:45 +00:00
|
|
|
|
await provider.GetRequiredService<ISettingManager>().ReloadSettingsAsync();
|
2023-10-06 16:12:35 +00:00
|
|
|
|
await provider.GetRequiredService<ICatalogueManager>().LoadPagesAsync();
|
2023-10-06 18:46:50 +00:00
|
|
|
|
provider.GetRequiredService<IFigureDataManager>();
|
2023-09-23 11:11:07 +00:00
|
|
|
|
|
|
|
|
|
provider.GetRequiredService<IWebSocketServer>().Start($"http://{configuration["Network:Game:Ip"]}:{configuration["Network:Game:Port"]}/");
|
|
|
|
|
|
|
|
|
|
quitEvent.WaitOne();
|