Disque\Connection\Manager::connect PHP Method

connect() public method

public connect ( )
    public function connect()
    {
        // If the manager was already connected, connect to a node from the last
        // HELLO response. This information is newer than the credentials
        // supplied by the user at the beginning.
        if ($this->wasAlreadyConnected()) {
            try {
                $this->switchNodeIfNeeded();
            } catch (ConnectionException $e) {
                // Ignore the error, we'll try reconnecting with credentials below
            }
        }
        // Use the user-supplied credentials in case this is the initial
        // connection.
        // If the reconnection attempt above didn't work, fall back
        // to the user-supplied credentials, too.
        if (!$this->isConnected()) {
            $currentNode = $this->findAvailableConnection();
            $this->switchToNode($currentNode);
        }
        return $this->getCurrentNode();
    }

Usage Example

Example #1
0
 /**
  * Connect to Disque
  *
  * @return array Connected node information
  * @throws Disque\Connection\ConnectionException
  */
 public function connect()
 {
     return $this->connectionManager->connect();
 }