From 9bcf030bc605043b55d35e3ca8c13d4fe3760a41 Mon Sep 17 00:00:00 2001 From: fritzy Date: Wed, 2 Apr 2008 19:48:52 +0000 Subject: [PATCH] * disconnect fixes git-svn-id: svn://netflint.net/xmpphp@11 ef36c318-a008-4979-b6e8-6b496270793b --- cli_longrun_example.php | 2 +- xmlstream.php | 27 ++++++++++++++++++++++++--- xmpp.php | 2 +- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/cli_longrun_example.php b/cli_longrun_example.php index 47067a1..be08ac5 100644 --- a/cli_longrun_example.php +++ b/cli_longrun_example.php @@ -1,6 +1,6 @@ connect(); while(!$conn->disconnected) { $payloads = $conn->processUntil(array('message', 'presence', 'end_stream', 'session_start')); diff --git a/xmlstream.php b/xmlstream.php index bb9415f..1090dfa 100644 --- a/xmlstream.php +++ b/xmlstream.php @@ -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); } diff --git a/xmpp.php b/xmpp.php index 54caaf9..c170fb7 100644 --- a/xmpp.php +++ b/xmpp.php @@ -35,7 +35,7 @@ class XMPP extends XMLStream { $this->password = $password; $this->resource = $resource; if(!$server) $server = $host; - $this->stream_start = '\n'; + $this->stream_start = ''; $this->stream_end = ''; $this->addHandler('features', 'http://etherx.jabber.org/streams', 'features_handler'); $this->addHandler('success', 'urn:ietf:params:xml:ns:xmpp-sasl', 'sasl_success_handler');