Exemple #1
0
 public function testToStringNameNamespaceSub()
 {
     $xmlobj = new XMPPHP_XMLObj('testName', 'testNameSpace');
     $sub1 = new XMPPHP_XMLObj('subName', 'subNameSpace');
     $xmlobj->subs = array($sub1);
     $expected = "<testname xmlns='testNameSpace' ><subname xmlns='subNameSpace' ></subname></testname>";
     $result = $xmlobj->toString();
     $this->assertSame($expected, $result);
 }
 /**
  * Handle a server-initiated message by passing it to our handlers.
  * @param \XMPPHP_XMLObj $message The message.
  */
 public function handleMessage(\XMPPHP_XMLObj $message)
 {
     try {
         $parsed = simplexml_load_string($message->toString());
         $payload = $parsed->event->asXml();
     } catch (\Exception $exception) {
         if ($this->logger !== null) {
             $this->logger->err("Problem parsing XML: " . $message->toString());
         }
         throw $exception;
     }
     try {
         foreach ($this->handlers as $handler) {
             $handler->handleNotification($payload);
         }
     } catch (\Exception $exception) {
         // Log exceptions, but don't stop them from propagating
         if ($this->logger !== null) {
             $this->logger->err("Caught " . \get_class($exception) . " while handling notification: " . $exception->getMessage());
         }
         throw $exception;
     }
 }