34 lines
816 B
C#
34 lines
816 B
C#
|
using System.Collections.Generic;
|
|||
|
|
|||
|
namespace ET
|
|||
|
{
|
|||
|
public class GateSessionKeyComponent : Entity
|
|||
|
{
|
|||
|
private readonly Dictionary<long, long> sessionKey = new Dictionary<long, long>();
|
|||
|
|
|||
|
public void Add(long key, long userId)
|
|||
|
{
|
|||
|
this.sessionKey.Add(key, userId);
|
|||
|
this.TimeoutRemoveKey(key).Coroutine();
|
|||
|
}
|
|||
|
|
|||
|
public long Get(long key)
|
|||
|
{
|
|||
|
|
|||
|
this.sessionKey.TryGetValue(key, out var account);
|
|||
|
return account;
|
|||
|
}
|
|||
|
|
|||
|
public void Remove(long key)
|
|||
|
{
|
|||
|
this.sessionKey.Remove(key);
|
|||
|
}
|
|||
|
|
|||
|
private async ETVoid TimeoutRemoveKey(long key)
|
|||
|
{
|
|||
|
await Game.Scene.GetComponent<TimerComponent>().WaitAsync(20000);
|
|||
|
this.sessionKey.Remove(key);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|