* 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
@ -290,6 +290,26 @@ class XMPPHP_XMLStream {
|
|||||||
public function isDisconnected() {
|
public function isDisconnected() {
|
||||||
return $this->connected;
|
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
|
* Process
|
||||||
@ -299,23 +319,7 @@ class XMPPHP_XMLStream {
|
|||||||
public function process() {
|
public function process() {
|
||||||
$updated = '';
|
$updated = '';
|
||||||
while(!$this->disconnect) {
|
while(!$this->disconnect) {
|
||||||
$read = array($this->socket);
|
$this->__process();
|
||||||
$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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,23 +333,7 @@ class XMPPHP_XMLStream {
|
|||||||
$start = time();
|
$start = time();
|
||||||
$updated = '';
|
$updated = '';
|
||||||
while(!$this->disconnected and ($timeout == -1 or time() - $start < $timeout)) {
|
while(!$this->disconnected and ($timeout == -1 or time() - $start < $timeout)) {
|
||||||
$read = array($this->socket);
|
$this->__process();
|
||||||
$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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,23 +353,7 @@ class XMPPHP_XMLStream {
|
|||||||
reset($this->until);
|
reset($this->until);
|
||||||
$updated = '';
|
$updated = '';
|
||||||
while(!$this->disconnected and $this->until[$event_key] and (time() - $start < $timeout or $timeout == -1)) {
|
while(!$this->disconnected and $this->until[$event_key] and (time() - $start < $timeout or $timeout == -1)) {
|
||||||
$read = array($this->socket);
|
$this->__process();
|
||||||
$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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(array_key_exists($event_key, $this->until_payload)) {
|
if(array_key_exists($event_key, $this->until_payload)) {
|
||||||
$payload = $this->until_payload[$event_key];
|
$payload = $this->until_payload[$event_key];
|
||||||
|
@ -143,14 +143,16 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream {
|
|||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $subject
|
* @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);
|
$to = htmlspecialchars($to);
|
||||||
$body = htmlspecialchars($body);
|
$body = htmlspecialchars($body);
|
||||||
$subject = htmlspecialchars($subject);
|
$subject = htmlspecialchars($subject);
|
||||||
|
|
||||||
$out = "<message from='{$this->fulljid}' to='$to' type='$type'>";
|
$out = "<message from='{$this->fulljid}' to='$to' type='$type'>";
|
||||||
if($subject) $out .= "<subject>$subject</subject>";
|
if($subject) $out .= "<subject>$subject</subject>";
|
||||||
$out .= "<body>$body</body></message>";
|
$out .= "<body>$body</body>";
|
||||||
|
if($payload) $out .= $payload;
|
||||||
|
$out .= "</message>";
|
||||||
|
|
||||||
$this->send($out);
|
$this->send($out);
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,6 @@ require_once "XMPP.php";
|
|||||||
*/
|
*/
|
||||||
protected function startXML($parser, $name, $attr) {
|
protected function startXML($parser, $name, $attr) {
|
||||||
if($this->xml_depth == 0 and $attr['version'] != '1.0') {
|
if($this->xml_depth == 0 and $attr['version'] != '1.0') {
|
||||||
print_r($attr);
|
|
||||||
$this->session_id = $attr['ID'];
|
$this->session_id = $attr['ID'];
|
||||||
$this->authenticate();
|
$this->authenticate();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user