Files
Fishing2Server/Hotfix/Authentication/System/TimeOut/AccountCacheInfoTimeOutSystem.cs
2025-07-27 23:46:43 +08:00

40 lines
1.1 KiB
C#
Raw Permalink 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;
// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
namespace NB.Authentication;
public sealed class AccountCacheInfoTimeOutDestroySystem : DestroySystem<AccountCacheInfoTimeOut>
{
protected override void Destroy(AccountCacheInfoTimeOut self)
{
if (self.TimerId != 0)
{
self.Scene.TimerComponent.Net.Remove(ref self.TimerId);
}
self.Key = null;
}
}
public static class AccountCacheInfoTimeOutSystem
{
public static void TimeOut(this AccountCacheInfoTimeOut self, string key, int timeout)
{
self.Key = key;
// 创建一个任务计时器、用在timeout时间后执行并且要清楚掉当前鉴权服务器缓存
var scene = self.Scene;
var runTimeId = self.RuntimeId;
self.TimerId = scene.TimerComponent.Net.OnceTimer(timeout, () =>
{
if (runTimeId != self.RuntimeId)
{
return;
}
self.TimerId = 0;
AuthenticationHelper.RemoveLoginAccounts(scene, self.Key,true);
});
}
}