graceful shutdown kill protocol + double session checking

This commit is contained in:
rfi
2023-11-14 21:12:15 +07:00
parent 726af535e1
commit e850a18d54
4 changed files with 40 additions and 6 deletions

View File

@@ -1,4 +1,5 @@
using AscNet.GameServer;
using AscNet.GameServer.Handlers;
using AscNet.GameServer.Commands;
using AscNet.Logging;
@@ -22,6 +23,17 @@ namespace AscNet
Task.Run(Server.Instance.Start);
SDKServer.SDKServer.Main(args);
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();
}
}
}
}