* added payload option to messages
git-svn-id: svn://netflint.net/xmpphp@47 ef36c318-a008-4979-b6e8-6b496270793b
This commit is contained in:
parent
d2b45506b5
commit
895021132c
@ -291,14 +291,7 @@ class XMPPHP_XMLStream {
|
||||
return $this->connected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function process() {
|
||||
$updated = '';
|
||||
while(!$this->disconnect) {
|
||||
private function __process() {
|
||||
$read = array($this->socket);
|
||||
$write = null;
|
||||
$except = null;
|
||||
@ -317,6 +310,17 @@ class XMPPHP_XMLStream {
|
||||
xml_parse($this->parser, $buff, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function process() {
|
||||
$updated = '';
|
||||
while(!$this->disconnect) {
|
||||
$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];
|
||||
|
@ -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 = "<message from='{$this->fulljid}' to='$to' type='$type'>";
|
||||
if($subject) $out .= "<subject>$subject</subject>";
|
||||
$out .= "<body>$body</body></message>";
|
||||
$out .= "<body>$body</body>";
|
||||
if($payload) $out .= $payload;
|
||||
$out .= "</message>";
|
||||
|
||||
$this->send($out);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user