using ET; using System; using System.Collections.Generic; namespace ET { public class GateSessionDisposeComponentDestroySystem: DestroySystem { public override void Destroy(GateSessionDisposeComponent self) { Log.Error($"掉线了"); self.ReConnect(); } } public class GateSessionDisposeComponent: Entity { private int timeInterval = 10 * 1000; private int reCount = 100; private long timerId; public void ReConnect() { timerId = TimerComponent.Instance.NewRepeatedTimer(timeInterval, () => { if (ReduceCount()) LoginHelper.ReLogin(); }); } private bool ReduceCount() { reCount--; if (reCount <= 0) { if (timerId != 0) TimerComponent.Instance.Remove(timerId); return false; } return true; } public void Init() { reCount = 100; } } }