Files
Fishing2Server/Hotfix/Outer/Authentication/System/TimeOut/AccountTimeOutSystem.cs
2025-07-16 17:47:53 +08:00

37 lines
1.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Fantasy;
using Fantasy.Entitas.Interface;
namespace Fantasy.Authentication;
public sealed class AccountTimeOutDestroySystem : DestroySystem<AccountTimeOut>
{
protected override void Destroy(AccountTimeOut self)
{
if (self.TimerId != 0)
{
self.Scene.TimerComponent.Net.Remove(ref self.TimerId);
}
}
}
public static class AccountTimeOutSystem
{
public static void TimeOut(this AccountTimeOut self, int timeout)
{
// 创建一个任务计时器、用在timeout时间后执行并且要清楚掉当前鉴权服务器缓存
var scene = self.Scene;
var account = (Account)self.Parent;
var accountRunTimeId = account.RuntimeId;
self.TimerId = scene.TimerComponent.Net.OnceTimer(timeout, () =>
{
if (accountRunTimeId != account.RuntimeId)
{
return;
}
self.TimerId = 0;
AuthenticationHelper.RemoveCache(scene, account.Username,true);
});
}
}