X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=extlib%2FXMPPHP%2FXMLStream.php;h=04877fda4c8636672f1e91d5e8669f7f7e010dc0;hb=69a1cea319f22362d197cb8a0fc9ab19abdf8548;hp=e59e95902cc9ac12dbc665476621e492d7d73f7e;hpb=695da8311a68cad52f859f6b89b66b82ae6ff26c;p=quix0rs-gnu-social.git diff --git a/extlib/XMPPHP/XMLStream.php b/extlib/XMPPHP/XMLStream.php index e59e95902c..04877fda4c 100644 --- a/extlib/XMPPHP/XMLStream.php +++ b/extlib/XMPPHP/XMLStream.php @@ -153,6 +153,10 @@ class XMPPHP_XMLStream { * @var boolean */ protected $use_ssl = false; + /** + * @var integer + */ + protected $reconnectTimeout = 30; /** * Constructor @@ -274,6 +278,8 @@ class XMPPHP_XMLStream { if(!$this->socket) { $this->log->log("Could not connect.", XMPPHP_Log::LEVEL_ERROR); $this->disconnected = true; + # Take it easy for a few seconds + sleep(min($timeout, 5)); } } while (!$this->socket && (time() - $starttime) < $timeout); @@ -290,13 +296,17 @@ class XMPPHP_XMLStream { */ public function doReconnect() { if(!$this->is_server) { - $this->log->log("Reconnecting...", XMPPHP_Log::LEVEL_WARNING); - $this->connect(30, false, false); + $this->log->log("Reconnecting ($this->reconnectTimeout)...", XMPPHP_Log::LEVEL_WARNING); + $this->connect($this->reconnectTimeout, false, false); $this->reset(); $this->event('reconnect'); } } + public function setReconnectTimeout($timeout) { + $this->reconnectTimeout = $timeout; + } + /** * Disconnect from XMPP Host */