/**
  * Event break the base loop on limit
  *
  * @param EventInterface $event
  */
 public function basic_timed_event_03(EventInterface $event)
 {
     $this->counter++;
     echo sprintf("Loop breaking persistent event call %s. Timeout: %s.\n", $event->getName(), $event->getTimeout());
     if ($this->counter === $this->limit) {
         $event->getBase()->loopBreak();
         echo sprintf("Call limit exceed for event %s. Loop break.\n", $event->getName());
     }
 }
示例#2
0
 /**
  * @param EventInterface $event
  * @group helper
  */
 public function eventHandlerInnerCallback(EventInterface $event)
 {
     $arguments = $event->getArguments();
     if (!isset($arguments['test_argument']) || !$arguments['test_argument'] instanceof \stdClass) {
         return;
     }
     $arguments['test_argument']->testParam = 1;
 }
 public function basic_sigint_event(EventInterface $event)
 {
     echo sprintf("This is a simple sigint event handler. Ivoked by %s \n", $event->getName());
     exit;
 }
示例#4
0
 /**
  * Add event to disabled stack
  * It may mey be removed manualy
  *
  * @param string|EventInterface $event
  * @param int $events Required only for buffer event
  *
  * @return bool
  */
 public function disableEvent($event, $events = null)
 {
     $name = $event instanceof EventInterface ? $event->getName() : $event;
     if ($this->exists($name) && !$this->isEventDisabled($name)) {
         /**
          * @var EventInterface $event
          */
         $event = $this->events[$name];
         $this->disabled[$name] = $event;
         $event->disable($events);
         return true;
     }
     return false;
 }