]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - extlib/XMPPHP/XMLStream.php
add inboxed and regenerate data objects
[quix0rs-gnu-social.git] / extlib / XMPPHP / XMLStream.php
index e59e95902cc9ac12dbc665476621e492d7d73f7e..04877fda4c8636672f1e91d5e8669f7f7e010dc0 100644 (file)
@@ -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
         */