fixed twice-running one-time timer listening
This commit is contained in:
		| @@ -30,8 +30,11 @@ class TimerListening extends Listening { | |||||||
| 	public function __construct(TimerListener $listener, $method, $milliSeconds, $oneTime = false, $instantCall = true) { | 	public function __construct(TimerListener $listener, $method, $milliSeconds, $oneTime = false, $instantCall = true) { | ||||||
| 		parent::__construct($listener, $method); | 		parent::__construct($listener, $method); | ||||||
|  |  | ||||||
| 		$this->deltaTime   = $milliSeconds / 1000.; | 		$this->deltaTime = $milliSeconds / 1000.; | ||||||
| 		$this->oneTime     = (bool)$oneTime; | 		$this->oneTime   = (bool)$oneTime; | ||||||
|  | 		if ($this->oneTime) { | ||||||
|  | 			$this->lastTrigger = time(true); | ||||||
|  | 		} | ||||||
| 		$this->instantCall = (bool)$instantCall; | 		$this->instantCall = (bool)$instantCall; | ||||||
| 		if (!$this->instantCall) { | 		if (!$this->instantCall) { | ||||||
| 			$this->lastTrigger = microtime(true); | 			$this->lastTrigger = microtime(true); | ||||||
|   | |||||||
| @@ -55,11 +55,20 @@ class TimerManager { | |||||||
|  |  | ||||||
| 		// Build Timer Listening | 		// Build Timer Listening | ||||||
| 		$listening = new TimerListening($listener, $method, $milliSeconds, $oneTime); | 		$listening = new TimerListening($listener, $method, $milliSeconds, $oneTime); | ||||||
| 		array_push($this->timerListenings, $listening); | 		$this->addTimerListening($listening); | ||||||
|  |  | ||||||
| 		return true; | 		return true; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * Add a Listening to the current List of managed Timers | ||||||
|  | 	 * | ||||||
|  | 	 * @param TimerListening $timerListening | ||||||
|  | 	 */ | ||||||
|  | 	public function addTimerListening(TimerListening $timerListening) { | ||||||
|  | 		array_push($this->timerListenings, $timerListening); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * Unregister a Timer Listening | 	 * Unregister a Timer Listening | ||||||
| 	 * | 	 * | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user