/** * 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(); }
/** * Disarm the internal timer * * @return boolean */ protected function _disarmTimer() { if ($this->_timer->isArmed()) { return $this->_timer->disarm(); } return true; }
/** * Arm the timer * * @param float|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, 'onTimeout'), 'options' => array('autoRemove' => 'before'))); $armed = $this->_timer->arm(); if (!$armed) { $this->_timer->flushEventListeners(); } return $armed; }
/** * 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(); } }
/** * Stop the interval timer * * @return boolean */ public function stop() { if (!$this->isRunning()) { $this->dispatchErrorEvent(self::ALREADY_STOPPED_ERR_CODE); return false; } // reset the timer $this->_timeoutTimer->reset(); // mark the widget as READY $this->_stateManager->setState(self::STATE_READY); // dispatch a INTERVAL_TIMER_STOPPED $this->dispatchEvent(new Streamwide_Engine_Events_Event(Streamwide_Engine_Events_Event::STOPPED)); return true; }
/** * Decrement the counter and give the user another try * * @param boolean $decrement * @return boolean */ protected function _retry($decrement = true) { if (true === $decrement) { $this->_counter->decrement(); } if ($this->_counter->hasMoreTries()) { $this->_timer->reset(); $this->_dtmfHandler->reset(); $this->_mediaPlayer->reset(); $this->dispatchErrorEvent(self::BAD_TRY_ERR_CODE); return $this->enter(); } else { $this->dispatchErrorEvent(self::NO_TRIES_LEFT_ERR_CODE); return false; } }
/** * 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; }
/** * 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 void */ protected function _resetDetectionDurationTimer() { if (isset($this->_timer)) { $this->_timer->reset(); } }
/** * @return void */ protected function _resetInternalWidgets() { $this->_relayer->reset(); if (isset($this->_timer)) { $this->_timer->reset(); } }