GameSessionKeyComponentSystem.cs 941 B

123456789101112131415161718192021222324252627282930
  1. namespace ET.Server
  2. {
  3. [FriendOf(typeof(GameSessionKeyComponent))]
  4. public static class GameSessionKeyComponentSystem
  5. {
  6. public static void Add(this GameSessionKeyComponent self, string key, string account)
  7. {
  8. self.sessionKey.Add(key, account);
  9. self.TimeoutRemoveKey(key).Coroutine();
  10. }
  11. public static string Get(this GameSessionKeyComponent self, string key)
  12. {
  13. string account = null;
  14. self.sessionKey.TryGetValue(key, out account);
  15. return account;
  16. }
  17. public static void Remove(this GameSessionKeyComponent self, string key)
  18. {
  19. self.sessionKey.Remove(key);
  20. }
  21. private static async ETTask TimeoutRemoveKey(this GameSessionKeyComponent self, string key)
  22. {
  23. await TimerComponent.Instance.WaitAsync(20000);
  24. self.sessionKey.Remove(key);
  25. }
  26. }
  27. }