Пример #1
0
Файл: Menu.php Проект: cwcw/cms
 /**
  * Arms the menu timer
  *
  * @return boolean
  */
 protected function _armTimer()
 {
     $this->_timer->addEventListener(Streamwide_Engine_Events_Event::TIMEOUT, array('callback' => array($this, 'onMenuTimeout'), 'options' => array('autoRemove' => 'before')));
     $armed = $this->_timer->arm();
     if (!$armed) {
         $this->_timer->flushEventListeners();
     }
     return $armed;
 }
Пример #2
0
 /**
  * Arm the timer
  *
  * @return boolean
  */
 protected function _armTimer()
 {
     $this->_timer->addEventListener(Streamwide_Engine_Events_Event::TIMEOUT, array('callback' => array($this, 'onTimeout'), 'options' => array('autoRemove' => 'before')));
     $this->_timer->setContextParams(array('timeoutType' => self::TIMEOUT_FIRSTDIGIT));
     $armed = $this->_timer->arm();
     if (!$armed) {
         $this->_timer->flushEventListeners();
     }
     return $armed;
 }
Пример #3
0
 /**
  * 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;
 }
Пример #4
0
 /**
  * @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;
 }
Пример #5
0
 /**
  * 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;
 }
Пример #6
0
 /**
  * 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;
 }