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

38 lines
993 B
C#
Raw Normal View History

2021-04-08 20:09:59 +08:00
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
{
2021-04-24 17:39:11 +08:00
await ETTask.CompletedTask;
using var llist=ListComponent<ETTask>.Create();
2021-04-11 19:50:39 +08:00
IEnumerable<Session> arr = OnLineComponent.Instance.GetAll();
foreach (Session session in arr)
2021-04-08 20:09:59 +08:00
{
2021-04-24 17:39:11 +08:00
llist.List.Add(Offline(session));
2021-04-08 20:09:59 +08:00
}
2021-04-24 17:39:11 +08:00
ETTaskHelper.WaitAll(llist.List);
2021-04-08 20:09:59 +08:00
}
catch (Exception e)
{
Log.Error(e);
}
}
2021-04-24 17:39:11 +08:00
private static async ETTask Offline(Session session)
{
session.Send(new G2C_ForceOffLine());
await TimerComponent.Instance.WaitAsync(300);
session.Dispose();
}
2021-04-08 20:09:59 +08:00
}
}