]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/liberalstomp.php
Merge branch 'master' of git@gitorious.org:statusnet/mainline into testing
[quix0rs-gnu-social.git] / lib / liberalstomp.php
index c9233843a4dfdb262cd7f1ea673967fb351020ff..3d38953fd2cac9b3770673a06876bd9b3de7c5bd 100644 (file)
@@ -33,6 +33,22 @@ class LiberalStomp extends Stomp
         return $this->_socket;
     }
 
+    /**
+     * Return the host we're currently connected to.
+     *
+     * @return string
+     */
+    function getServer()
+    {
+        $idx = $this->_currentHost;
+        if ($idx >= 0) {
+            $host = $this->_hosts[$idx];
+            return "$host[0]:$host[1]";
+        } else {
+            return '[unconnected]';
+        }
+    }
+
     /**
      * Make socket connection to the server
      * We also set the stream to non-blocking mode, since we'll be
@@ -71,10 +87,12 @@ class LiberalStomp extends Stomp
             // @fixme this sometimes hangs in blocking mode...
             // shouldn't we have been idle until we found there's more data?
             $read = fread($this->_socket, $rb);
-            if ($read === false) {
-                $this->_reconnect();
+            if ($read === false || ($read === '' && feof($this->_socket))) {
+                // @fixme possibly attempt an auto reconnect as old code?
+                throw new StompException("Error reading");
+                //$this->_reconnect();
                 // @fixme this will lose prior items
-                return $this->readFrames();
+                //return $this->readFrames();
             }
             $data .= $read;
             if (strpos($data, "\x00") !== false) {