Example #1
0
 /**
  * Outputs the event data for users
  * Use $eventParams if you only want to output certain data, but not all available event parameters
  * 
  * @param Event $event
  * @param array $eventParams
  * @return string
  */
 public static function outputEventInfo($event, $eventParams = "")
 {
     if ($eventParams == "") {
         $eventParams = Event::$eventParamsNames;
     }
     $output = "<div id='content'><table id = 'event_info'>";
     foreach ($eventParams as $title => $param) {
         if ($param == 'topicID') {
             $value = $event->getTopic();
         } else {
             if ($param == 'mandantID') {
                 $value = $event->getMandant();
             } else {
                 if ($param == 'addressID') {
                     $value = $event->getAddress()->getAddressValue(true);
                 } else {
                     if ($param == 'eventType') {
                         $value = Event::$eventTypes[$event->getEventType()];
                     } else {
                         $value = $event->getParam($param);
                     }
                 }
             }
         }
         if ($param != 'event_visible') {
             $output .= "<tr><th>{$title}</th><td>" . $value . "</td></tr>";
         }
     }
     $output .= '</table>';
     return $output;
 }
Example #2
0
 protected function handleIncome($data)
 {
     $this->debug("PHPSusi handleIncome:\n" . $data);
     $evt = new Event();
     $evt->fromString($data);
     if ($evt->getType() === "consumerEvent") {
         $topic = $evt->getTopic();
         if (array_key_exists($topic, $this->consumer_callbacks)) {
             $consumer_callbacks = $this->consumer_callbacks[$topic];
             foreach ($consumer_callbacks as $callback) {
                 try {
                     $callback["handler"]($evt);
                 } catch (Exception $e) {
                     print $e;
                 }
             }
         }
     }
     if ($evt->getType() === "processorEvent") {
         $topic = $evt->getTopic();
         if (array_key_exists($topic, $this->processor_callbacks)) {
             $processor_callbacks = $this->processor_callbacks[$topic];
             foreach ($processor_callbacks as $callback) {
                 try {
                     $callback["handler"]($evt);
                 } catch (Exception $e) {
                     print $e;
                 }
             }
             $this->ack($evt->getData());
         }
     }
     if ($evt->getType() === "ack") {
         // ID as string
         $id = $evt->getStr_ID();
         if (array_key_exists($id, $this->finish_handlers)) {
             $finish_handler = $this->finish_handlers[$id];
             try {
                 $finish_handler($evt);
                 // delete callback from memory
                 unset($this->finish_handlers[$id]);
             } catch (Exception $e) {
                 print $e;
             }
         }
     }
     if ($evt->getType() === "status") {
         if ($evt->getError() == true) {
             $error_msg = $evt->getErrorMsg();
             echo "server error:" . $error_msg . "\n";
         }
     }
 }