* disconnect fixes
git-svn-id: svn://netflint.net/xmpphp@11 ef36c318-a008-4979-b6e8-6b496270793b
This commit is contained in:
parent
98234cdc2c
commit
9bcf030bc6
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
include("xmpp.php");
|
||||
$conn = new XMPP('talk.google.com', 5222, 'user', 'password', 'xmpphp', 'gmail.com', $printlog=True, $loglevel=LOGGING_VERBOSE);
|
||||
$conn = new XMPP('talk.google.com', 5222, 'user', 'password', 'xmpphp', 'gmail.com', $printlog=True, $loglevel=LOGGING_INFO);
|
||||
$conn->connect();
|
||||
while(!$conn->disconnected) {
|
||||
$payloads = $conn->processUntil(array('message', 'presence', 'end_stream', 'session_start'));
|
||||
|
@ -99,7 +99,14 @@ class XMLStream {
|
||||
$updated = stream_select($read, $write, $except, 1);
|
||||
if ($updated > 0) {
|
||||
$buff = fread($this->socket, 1024);
|
||||
if(!$buff and $this->reconnect) $this->doReconnect();
|
||||
if(!$buff) {
|
||||
if($this->reconnect) {
|
||||
$this->doReconnect();
|
||||
} else {
|
||||
fclose($this->socket);
|
||||
return False;
|
||||
}
|
||||
}
|
||||
$this->log->log("RECV: $buff", LOGGING_VERBOSE);
|
||||
xml_parse($this->parser, $buff, False);
|
||||
}
|
||||
@ -116,7 +123,14 @@ class XMLStream {
|
||||
$updated = stream_select($read, $write, $except, 1);
|
||||
if ($updated > 0) {
|
||||
$buff = fread($this->socket, 1024);
|
||||
if(!$buff and $this->reconnect) $this->doReconnect();
|
||||
if(!$buff) {
|
||||
if($this->reconnect) {
|
||||
$this->doReconnect();
|
||||
} else {
|
||||
fclose($this->socket);
|
||||
return False;
|
||||
}
|
||||
}
|
||||
$this->log->log("RECV: $buff", LOGGING_VERBOSE);
|
||||
xml_parse($this->parser, $buff, False);
|
||||
}
|
||||
@ -136,7 +150,14 @@ class XMLStream {
|
||||
$updated = stream_select($read, $write, $except, 1);
|
||||
if ($updated > 0) {
|
||||
$buff = fread($this->socket, 1024);
|
||||
if(!$buff and $this->reconnect) $this->doReconnect();
|
||||
if(!$buff) {
|
||||
if($this->reconnect) {
|
||||
$this->doReconnect();
|
||||
} else {
|
||||
fclose($this->socket);
|
||||
return False;
|
||||
}
|
||||
}
|
||||
$this->log->log("RECV: $buff", LOGGING_VERBOSE);
|
||||
xml_parse($this->parser, $buff, False);
|
||||
}
|
||||
|
2
xmpp.php
2
xmpp.php
@ -35,7 +35,7 @@ class XMPP extends XMLStream {
|
||||
$this->password = $password;
|
||||
$this->resource = $resource;
|
||||
if(!$server) $server = $host;
|
||||
$this->stream_start = '<stream:stream to="' . $server . '" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" version="1.0">\n';
|
||||
$this->stream_start = '<stream:stream to="' . $server . '" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" version="1.0">';
|
||||
$this->stream_end = '</stream:stream>';
|
||||
$this->addHandler('features', 'http://etherx.jabber.org/streams', 'features_handler');
|
||||
$this->addHandler('success', 'urn:ietf:params:xml:ns:xmpp-sasl', 'sasl_success_handler');
|
||||
|
Loading…
Reference in New Issue
Block a user