SessionComponent.cs 829 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. 
  2. using System.ComponentModel;
  3. namespace KYFramework.Network
  4. {
  5. [ObjectSystem]
  6. public class SessionComponentAwakeSystem : AwakeSystem<SessionComponent>
  7. {
  8. public override void Awake(SessionComponent self)
  9. {
  10. self.Awake();
  11. Log.Info("会话组件初始化完毕!");
  12. }
  13. }
  14. public class SessionComponent : Component
  15. {
  16. public static SessionComponent Instance;
  17. public Session Session;
  18. public void Awake()
  19. {
  20. Instance = this;
  21. }
  22. public override void Dispose()
  23. {
  24. if (this.IsDisposed)
  25. {
  26. return;
  27. }
  28. base.Dispose();
  29. this.Session?.Dispose();
  30. this.Session = null;
  31. Instance = null;
  32. }
  33. }
  34. }