fixed twice-running one-time timer listening

This commit is contained in:
Steffen Schröder 2014-05-19 15:22:53 +02:00
parent 55cc74ec84
commit 6fbeab1cd6
2 changed files with 15 additions and 3 deletions

View File

@ -32,6 +32,9 @@ class TimerListening extends Listening {
$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);

View File

@ -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
* *