fixed twice-running one-time timer listening
This commit is contained in:
parent
55cc74ec84
commit
6fbeab1cd6
@ -30,8 +30,11 @@ class TimerListening extends Listening {
|
||||
public function __construct(TimerListener $listener, $method, $milliSeconds, $oneTime = false, $instantCall = true) {
|
||||
parent::__construct($listener, $method);
|
||||
|
||||
$this->deltaTime = $milliSeconds / 1000.;
|
||||
$this->oneTime = (bool)$oneTime;
|
||||
$this->deltaTime = $milliSeconds / 1000.;
|
||||
$this->oneTime = (bool)$oneTime;
|
||||
if ($this->oneTime) {
|
||||
$this->lastTrigger = time(true);
|
||||
}
|
||||
$this->instantCall = (bool)$instantCall;
|
||||
if (!$this->instantCall) {
|
||||
$this->lastTrigger = microtime(true);
|
||||
|
@ -55,11 +55,20 @@ class TimerManager {
|
||||
|
||||
// Build Timer Listening
|
||||
$listening = new TimerListening($listener, $method, $milliSeconds, $oneTime);
|
||||
array_push($this->timerListenings, $listening);
|
||||
$this->addTimerListening($listening);
|
||||
|
||||
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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user