Ejemplo n.º 1
0
 public static function xml($xml, $jaxl)
 {
     $xml = JAXLPlugin::execute('jaxl_send_xml', $xml, $jaxl);
     if ($jaxl->mode == "cgi") {
         JAXLPlugin::execute('jaxl_send_body', $xml, $jaxl);
     } else {
         if ($jaxl->lastSendTime && JAXLUtil::getTime() - $jaxl->lastSendTime < JAXL_XMPP_SEND_RATE) {
             sleep(JAXL_XMPP_SEND_SLEEP);
         }
         $jaxl->lastSendTime = JAXLUtil::getTime();
         if ($jaxl->stream) {
             if (($ret = fwrite($jaxl->stream, $xml)) !== false) {
                 JAXLog::log("[[XMPPSend]] {$ret}\n" . $xml, 4, $jaxl);
             } else {
                 JAXLog::log("[[XMPPSend]] Failed\n" . $xml, 1, $jaxl);
             }
             return $ret;
         } else {
             JAXLog::log("Jaxl stream not connected to jabber host, unable to send xmpp payload...", 1, $jaxl);
             return false;
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Send XMPP XML packet over connected stream
  */
 protected function _sendXML($xml)
 {
     if ($this->stream && $xml != '') {
         $read = array();
         $write = array($this->stream);
         $except = array();
         $secs = 0;
         $usecs = 200000;
         if (false === ($changed = @stream_select($read, $write, $except, $secs, $usecs))) {
             //removed ref
             $this->log("[[XMPPSend]] \nError while trying to send packet", 5);
             throw new JAXLException("[[XMPPSend]] \nError while trying to send packet");
             return 0;
         } else {
             if ($changed > 0) {
                 $this->lastSendTime = JAXLUtil::getTime();
                 // this can be resource consuming for large payloads rcvd
                 $xmls = JAXLUtil::splitXML($xml);
                 $pktCnt = count($xmls);
                 $this->totalSentPkt += $pktCnt;
                 $ret = @fwrite($this->stream, $xml);
                 $this->totalSentSize += $ret;
                 $this->log("[[XMPPSend]] {$ret}\n" . $xml, 4);
                 return $ret;
             } else {
                 if ($changed === 0) {
                     $this->obuffer .= $xml;
                     $this->log("[[XMPPSend]] Not ready for write, obuffer size:" . strlen($this->obuffer), 1);
                     return 0;
                 } else {
                     $this->obuffer .= $xml;
                     $this->log("[[XMPPSend]] Something horibly wrong here", 1);
                     return 0;
                 }
             }
         }
     } else {
         if ($xml == '') {
             $this->log("[[XMPPSend]] Tried to send an empty stanza, not processing", 1);
             return 0;
         } else {
             $this->log("[[XMPPSend]] \nJaxl stream not connected to jabber host, unable to send xmpp payload...");
             throw new JAXLException("[[XMPPSend]] Jaxl stream not connected to jabber host, unable to send xmpp payload...");
             return 0;
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Send XMPP XML packet over connected stream
  */
 protected function _sendXML($xml)
 {
     if ($this->stream) {
         $this->lastSendTime = JAXLUtil::getTime();
         if (($ret = fwrite($this->stream, $xml)) !== false) {
             $this->log("[[XMPPSend]] {$ret}\n" . $xml, 4);
         } else {
             $this->log("[[XMPPSend]] Failed\n" . $xml, 1);
         }
         return $ret;
     } else {
         $this->log("Jaxl stream not connected to jabber host, unable to send xmpp payload...", 1);
         return false;
     }
 }