diff --git a/XMPPHP/XMLStream.php b/XMPPHP/XMLStream.php index 4bdbc30..0193e10 100644 --- a/XMPPHP/XMLStream.php +++ b/XMPPHP/XMLStream.php @@ -290,6 +290,26 @@ class XMPPHP_XMLStream { public function isDisconnected() { return $this->connected; } + + private function __process() { + $read = array($this->socket); + $write = null; + $except = null; + $updated = stream_select($read, $write, $except, 1); + if ($updated > 0) { + $buff = @fread($this->socket, 1024); + if(!$buff) { + if($this->reconnect) { + $this->doReconnect(); + } else { + fclose($this->socket); + return false; + } + } + $this->log->log("RECV: $buff", XMPPHP_Log::LEVEL_VERBOSE); + xml_parse($this->parser, $buff, false); + } + } /** * Process @@ -299,23 +319,7 @@ class XMPPHP_XMLStream { public function process() { $updated = ''; while(!$this->disconnect) { - $read = array($this->socket); - $write = null; - $except = null; - $updated = stream_select($read, $write, $except, 1); - if ($updated > 0) { - $buff = @fread($this->socket, 1024); - if(!$buff) { - if($this->reconnect) { - $this->doReconnect(); - } else { - fclose($this->socket); - return false; - } - } - $this->log->log("RECV: $buff", XMPPHP_Log::LEVEL_VERBOSE); - xml_parse($this->parser, $buff, false); - } + $this->__process(); } } @@ -329,23 +333,7 @@ class XMPPHP_XMLStream { $start = time(); $updated = ''; while(!$this->disconnected and ($timeout == -1 or time() - $start < $timeout)) { - $read = array($this->socket); - $write = null; - $except = null; - $updated = stream_select($read, $write, $except, 1); - if ($updated > 0) { - $buff = @fread($this->socket, 1024); - if(!$buff) { - if($this->reconnect) { - $this->doReconnect(); - } else { - fclose($this->socket); - return false; - } - } - $this->log->log("RECV: $buff", XMPPHP_Log::LEVEL_VERBOSE); - xml_parse($this->parser, $buff, false); - } + $this->__process(); } } @@ -365,23 +353,7 @@ class XMPPHP_XMLStream { reset($this->until); $updated = ''; while(!$this->disconnected and $this->until[$event_key] and (time() - $start < $timeout or $timeout == -1)) { - $read = array($this->socket); - $write = null; - $except = null; - $updated = stream_select($read, $write, $except, 1); - if ($updated > 0) { - $buff = @fread($this->socket, 1024); - if(!$buff) { - if($this->reconnect) { - $this->doReconnect(); - } else { - fclose($this->socket); - return false; - } - } - $this->log->log("RECV: $buff", XMPPHP_Log::LEVEL_VERBOSE); - xml_parse($this->parser, $buff, false); - } + $this->__process(); } if(array_key_exists($event_key, $this->until_payload)) { $payload = $this->until_payload[$event_key]; diff --git a/XMPPHP/XMPP.php b/XMPPHP/XMPP.php index 1a21546..5ba4095 100644 --- a/XMPPHP/XMPP.php +++ b/XMPPHP/XMPP.php @@ -143,14 +143,16 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { * @param string $type * @param string $subject */ - public function message($to, $body, $type = 'chat', $subject = null) { + public function message($to, $body, $type = 'chat', $subject = null, $payload = null) { $to = htmlspecialchars($to); $body = htmlspecialchars($body); $subject = htmlspecialchars($subject); $out = ""; if($subject) $out .= "$subject"; - $out .= "$body"; + $out .= "$body"; + if($payload) $out .= $payload; + $out .= ""; $this->send($out); } diff --git a/XMPPHP/XMPP_Old.php b/XMPPHP/XMPP_Old.php index e1be4c7..ab0466e 100644 --- a/XMPPHP/XMPP_Old.php +++ b/XMPPHP/XMPP_Old.php @@ -55,7 +55,6 @@ require_once "XMPP.php"; */ protected function startXML($parser, $name, $attr) { if($this->xml_depth == 0 and $attr['version'] != '1.0') { - print_r($attr); $this->session_id = $attr['ID']; $this->authenticate(); }