2023-11-13 12:10:02 +00:00
|
|
|
|
using AscNet.GameServer;
|
2023-11-14 14:12:15 +00:00
|
|
|
|
using AscNet.GameServer.Handlers;
|
2023-11-13 12:10:02 +00:00
|
|
|
|
using AscNet.GameServer.Commands;
|
2023-10-14 17:39:26 +00:00
|
|
|
|
using AscNet.Logging;
|
2023-10-06 13:29:27 +00:00
|
|
|
|
|
|
|
|
|
namespace AscNet
|
|
|
|
|
{
|
|
|
|
|
internal class Program
|
|
|
|
|
{
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
2023-11-13 12:10:02 +00:00
|
|
|
|
// TODO: Add LogLevel parsing from appsettings file
|
2023-10-14 17:39:26 +00:00
|
|
|
|
LoggerFactory.InitializeLogger(new Logger(typeof(Program), LogLevel.DEBUG, LogLevel.DEBUG));
|
|
|
|
|
LoggerFactory.Logger.Info("Starting...");
|
2023-11-11 07:28:21 +00:00
|
|
|
|
|
2023-10-14 15:01:49 +00:00
|
|
|
|
#if DEBUG
|
|
|
|
|
if (Common.Common.config.VerboseLevel < Common.VerboseLevel.Debug)
|
|
|
|
|
Common.Common.config.VerboseLevel = Common.VerboseLevel.Debug;
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-10-10 09:56:08 +00:00
|
|
|
|
PacketFactory.LoadPacketHandlers();
|
2023-11-13 12:10:02 +00:00
|
|
|
|
CommandFactory.LoadCommands();
|
|
|
|
|
|
2023-10-14 17:39:26 +00:00
|
|
|
|
Task.Run(Server.Instance.Start);
|
2023-10-06 13:29:27 +00:00
|
|
|
|
SDKServer.SDKServer.Main(args);
|
2023-11-14 14:12:15 +00:00
|
|
|
|
|
|
|
|
|
AppDomain.CurrentDomain.ProcessExit += new EventHandler(KillProtocol);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void KillProtocol(object? sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
foreach (var session in Server.Instance.Sessions)
|
|
|
|
|
{
|
|
|
|
|
session.Value.SendPush(new ShutdownNotify());
|
|
|
|
|
session.Value.DisconnectProtocol();
|
|
|
|
|
}
|
2023-10-06 13:29:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|