PhpOrient\Protocols\Binary\Operations\DbOpen::_read PHP Method

_read() protected method

Read the response from the socket.
protected _read ( ) : PhpOrient\Protocols\Common\ClustersMap
return PhpOrient\Protocols\Common\ClustersMap
    protected function _read()
    {
        $sessionId = $this->_readInt();
        $this->_transport->setSessionId($sessionId);
        $this->_transport->databaseOpened = true;
        $this->_transport->databaseName = $this->database;
        $this->_transport->connected = false;
        if ($this->_transport->getProtocolVersion() > 26) {
            $token = $this->_readString();
            # token
            if (empty($token)) {
                $this->_transport->setRequestToken(false);
            }
            $this->_transport->setToken($token);
        }
        $totalClusters = $this->_readShort();
        $dataClusters = [];
        for ($i = 0; $i < $totalClusters; $i++) {
            if ($this->_transport->getProtocolVersion() < 24) {
                $dataClusters[] = ['name' => $this->_readString(), 'id' => $this->_readShort(), 'type' => $this->_readString(), 'dataSegment' => $this->_readShort()];
            } else {
                $dataClusters[] = ['name' => $this->_readString(), 'id' => $this->_readShort()];
            }
        }
        # cluster config string ( -1 )
        # cluster release
        $cluster_list = ['sessionId' => $sessionId, 'dataClusters' => $dataClusters, 'servers' => CSV::unserialize($this->_readString()), 'release' => $this->_readString()];
        $this->_transport->setClustersMap(ClustersMap::fromConfig($cluster_list));
        if (!empty($cluster_list['servers'])) {
            $list = [];
            foreach ($cluster_list['servers']['members'] as $node) {
                $list[] = new OrientNode($node);
            }
            $this->_transport->setNodesList($list);
            # LIST WITH THE NEW CLUSTER CFG
        }
        $this->_transport->setOrientVersion(OrientVersion::fromConfig($cluster_list));
        return $this->_transport->getClusterMap();
    }