using System.ComponentModel;

namespace KYFramework.Network
{
    [ObjectSystem]
    public class SessionComponentAwakeSystem : AwakeSystem<SessionComponent>
    {
        public override void Awake(SessionComponent self)
        {
            self.Awake();

            Log.Info("会话组件初始化完毕!");
        }
    }

    public class SessionComponent : Component
    {
        public static SessionComponent Instance;

        public Session Session;

        public void Awake()
        {
            Instance = this;
        }

        public override void Dispose()
        {
            if (this.IsDisposed)
            {
                return;
            }

            base.Dispose();

            this.Session?.Dispose();
            this.Session = null;
            Instance = null;
        }
    }
}