CTT/Server/Hotfix/Game/Event/CloseServerEvent.cs

38 lines
993 B
C#

using ET.EventType;
using System;
using System.Collections.Generic;
using System.Text;
namespace ET
{
public class CloseServerEvent : AEvent<EventType.CloseServer>
{
public override async ETTask Run(CloseServer a)
{
try
{
await ETTask.CompletedTask;
using var llist=ListComponent<ETTask>.Create();
IEnumerable<Session> arr = OnLineComponent.Instance.GetAll();
foreach (Session session in arr)
{
llist.List.Add(Offline(session));
}
ETTaskHelper.WaitAll(llist.List);
}
catch (Exception e)
{
Log.Error(e);
}
}
private static async ETTask Offline(Session session)
{
session.Send(new G2C_ForceOffLine());
await TimerComponent.Instance.WaitAsync(300);
session.Dispose();
}
}
}