/** * Arm the internal timer * * @param integer $delay * @return boolean */ protected function _armTimer($delay) { $this->_timer->reset(); $this->_timer->setOptions(array(Streamwide_Engine_Timer_Timeout::OPT_DELAY => $delay)); $this->_timer->addEventListener(Streamwide_Engine_Events_Event::TIMEOUT, array('callback' => array($this, 'deactivate'), 'options' => array('autoRemove' => 'before'))); return $this->_timer->arm(); }
/** * Arm the timer * * @return void */ protected function _armTimer() { $this->_timer->reset(); $this->_timer->setOptions(array(Streamwide_Engine_Timer_Timeout::OPT_DELAY => $this->_ringDuration)); $this->_timer->addEventListener(Streamwide_Engine_Events_Event::TIMEOUT, array('callback' => array($this, 'onTimeout'), 'options' => array('autoRemove' => 'before'))); $this->_timer->arm(); }
/** * Rearm the timer * * @return boolean */ protected function _rearmTimer() { $delay = $this->_options[self::OPT_INTER_DIGIT_TIMEOUT]; $this->_timer->setContextParams(array('timeoutType' => self::TIMEOUT_INTERDIGIT)); if ($this->_timer->isArmed()) { return $this->_timer->rearm($delay); } else { $this->_timer->setOptions(array(Streamwide_Engine_Timer_Timeout::OPT_DELAY => $delay)); $this->_timer->addEventListener(Streamwide_Engine_Events_Event::TIMEOUT, array('callback' => array($this, 'onTimeout'), 'options' => array('autoRemove' => 'before'))); return $this->_timer->arm(); } }
/** * @param float|integer $detectionDuration * @param string $callback * @return boolean */ protected function _armDetectionDurationTimer($detectionDuration, $callback = 'onTimeout') { if (isset($this->_timer) && $detectionDuration > 0) { $this->_timer->reset(); $this->_timer->setOptions(array(Streamwide_Engine_Timer_Timeout::OPT_DELAY => $detectionDuration)); $this->_timer->addEventListener(Streamwide_Engine_Events_Event::TIMEOUT, array('callback' => array($this, $callback), 'options' => array('autoRemove' => 'before'))); $armed = $this->_timer->arm(); if (!$armed) { $this->_timer->flushEventListeners(); return false; } } return true; }
/** * Start the interval timer * * @return boolean */ public function start() { if ($this->isRunning()) { $this->dispatchErrorEvent(self::ALREADY_RUNNING_ERR_CODE); return false; } $interval = $this->_options[self::OPT_INTERVAL]; $this->_timeoutTimer->setOptions(array(Streamwide_Engine_Timer_Timeout::OPT_DELAY => $interval)); $this->_timeoutTimer->addEventListener(Streamwide_Engine_Events_Event::TIMEOUT, array('callback' => array($this, 'onTimeout'))); $armed = $this->_timeoutTimer->arm(); if (!$armed) { $this->_timeoutTimer->flushEventListeners(); return false; } // mark the widget as running $this->_stateManager->setState(self::STATE_RUNNING); // dispatch a INTERVAL_TIMER_RUNNING event $this->dispatchEvent(new Streamwide_Engine_Events_Event(Streamwide_Engine_Events_Event::RUNNING)); return true; }
/** * Handle the delaying of the RECORDER_STOPPED event (if it's the case). This is a workaround for a problem * in SW Engine where the recorded file is not immediately available after sending the RECORDSTOP signal * * @return void * @throws RuntimeException */ protected function _delayRecorderStoppedEventDispatch() { $event = new Streamwide_Engine_Events_Event(Streamwide_Engine_Events_Event::STOPPED); $event->setParam('recordStartTime', $this->_recordingStartTime); $event->setParam('recordStopTime', $this->_recordingStopTime); $delay = $this->_options[self::OPT_RECORDER_STOPPED_EVENT_DISPATCH_DELAY]; if (0 === $delay) { $this->dispatchEvent($event); return true; } if (null === $this->_timer) { throw new RuntimeException('Timer object not set'); } $this->_timer->reset(); $this->_timer->setOptions(array(Streamwide_Engine_Timer_Timeout::OPT_DELAY => $delay)); $this->_timer->addEventListener(Streamwide_Engine_Events_Event::TIMEOUT, array('callback' => array($this, 'dispatchEvent'), 'args' => $event, 'options' => array('autoRemove' => 'before'))); $armed = $this->_timer->arm(); if (!$armed) { $this->_timer->flushEventListeners(); return false; } return true; }
/** * Initialize the timer widget * * @return void */ protected function _initTimer() { $this->_timer->reset(); $timeout = $this->_options[self::OPT_TIMEOUT]; $this->_timer->setOptions(array(Streamwide_Engine_Timer_Timeout::OPT_DELAY => $timeout)); }
/** * Time the playing of the fax tone. When this timer expires we need to create the * fax environment manually (if it has not been created automatically for us) * * @return void */ protected function _timeFaxTonePlaying() { $this->_timer->reset(); $this->_timer->setOptions(array(Streamwide_Engine_Timer_Timeout::OPT_DELAY => self::FAX_TONE_PLAY_TIMEOUT)); $this->_timer->addEventListener(Streamwide_Engine_Events_Event::TIMEOUT, array('callback' => array($this, 'onFaxPlayingTimeout'), 'options' => array('autoRemove' => 'before'))); $this->_timer->arm(); }
/** * @return boolean */ protected function _armTimer() { $listeningDelay = $this->_options[self::OPT_LISTENING_DELAY]; if (isset($this->_timer) && $listeningDelay > 0) { $this->_timer->reset(); $this->_timer->setOptions(array(Streamwide_Engine_Timer_Timeout::OPT_DELAY => $listeningDelay)); $this->_timer->addEventListener(Streamwide_Engine_Events_Event::TIMEOUT, array('callback' => array($this, 'onListeningTimeout'), 'options' => array('autoRemove' => 'before'))); if (!$this->_timer->arm()) { $this->_timer->reset(); $this->dispatchErrorEvent(self::TIMER_ARM_ERR_CODE); return false; } } return true; }