mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
Make stats update after 10 kills so we don't wait quite as long
Gracefully disconnect clients on shutting down again
This commit is contained in:
@ -572,6 +572,30 @@ namespace IW4MAdmin
|
||||
};
|
||||
}
|
||||
|
||||
private async Task ShutdownInternal()
|
||||
{
|
||||
foreach (var client in GetClientsAsList())
|
||||
{
|
||||
await client.OnDisconnect();
|
||||
|
||||
var e = new GameEvent()
|
||||
{
|
||||
Type = GameEvent.EventType.Disconnect,
|
||||
Owner = this,
|
||||
Origin = client
|
||||
};
|
||||
|
||||
Manager.GetEventHandler().AddEvent(e);
|
||||
|
||||
await e.WaitAsync(Utilities.DefaultCommandTimeout, new CancellationTokenRegistration().Token);
|
||||
}
|
||||
|
||||
foreach (var plugin in SharedLibraryCore.Plugins.PluginImporter.ActivePlugins)
|
||||
{
|
||||
await plugin.OnUnloadAsync();
|
||||
}
|
||||
}
|
||||
|
||||
DateTime start = DateTime.Now;
|
||||
DateTime playerCountStart = DateTime.Now;
|
||||
DateTime lastCount = DateTime.Now;
|
||||
@ -579,18 +603,12 @@ namespace IW4MAdmin
|
||||
override public async Task<bool> ProcessUpdatesAsync(CancellationToken cts)
|
||||
{
|
||||
try
|
||||
{
|
||||
#region SHUTDOWN
|
||||
if (Manager.CancellationToken.IsCancellationRequested)
|
||||
{
|
||||
if (cts.IsCancellationRequested)
|
||||
{
|
||||
foreach (var plugin in SharedLibraryCore.Plugins.PluginImporter.ActivePlugins)
|
||||
{
|
||||
await plugin.OnUnloadAsync();
|
||||
}
|
||||
|
||||
await ShutdownInternal();
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
try
|
||||
{
|
||||
@ -738,6 +756,12 @@ namespace IW4MAdmin
|
||||
return true;
|
||||
}
|
||||
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
await ShutdownInternal();
|
||||
return true;
|
||||
}
|
||||
|
||||
// this one is ok
|
||||
catch (ServerException e)
|
||||
{
|
||||
|
Reference in New Issue
Block a user