public override void Load(SessionIdleCheckerComponent self) { RepeatedTimer repeatedTimer = TimerComponent.Instance.GetRepeatedTimer(self.RepeatedTimer); if (repeatedTimer != null) { repeatedTimer.Callback = self.Check; } }
/// <summary> /// 创建一个RepeatedTimer /// </summary> /// <param name="time"></param> /// <param name="action"></param> /// <returns></returns> public long NewRepeatedTimer(long time, Action action) { if (time < 30) { throw new Exception($"repeated time < 30"); } long tillTime = TimeHelper.Now() + time; RepeatedTimer timer = EntityFactory.CreateWithParent <RepeatedTimer, long, Action>(this, time, action); this.timers[timer.Id] = timer; AddToTimeId(tillTime, timer.Id); return(timer.Id); }