mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using System;
|
|
|
|
namespace ET
|
|
{
|
|
[EntitySystemOf(typeof(SessionAcceptTimeoutComponent))]
|
|
[FriendOf(typeof(SessionAcceptTimeoutComponent))]
|
|
public static partial class SessionAcceptTimeoutComponentHelper
|
|
{
|
|
[Invoke(TimerInvokeType.SessionAcceptTimeout)]
|
|
public class SessionAcceptTimeout: ATimer<SessionAcceptTimeoutComponent>
|
|
{
|
|
protected override void Run(SessionAcceptTimeoutComponent self)
|
|
{
|
|
try
|
|
{
|
|
self.Parent.Dispose();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log.Error($"move timer error: {self.Id}\n{e}");
|
|
}
|
|
}
|
|
}
|
|
|
|
[EntitySystem]
|
|
private static void Awake(this SessionAcceptTimeoutComponent self)
|
|
{
|
|
self.Timer = self.Fiber().TimerComponent.NewOnceTimer(self.Fiber().TimeInfo.ServerNow() + 5000, TimerInvokeType.SessionAcceptTimeout, self);
|
|
}
|
|
|
|
[EntitySystem]
|
|
private static void Destroy(this SessionAcceptTimeoutComponent self)
|
|
{
|
|
self.Fiber().TimerComponent?.Remove(ref self.Timer);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
} |