public function touchCursor()
{
if (!$this->cursor) {
if (!$this->inited) {
$this->inited = true;
$this->cache->get('_rp', function ($answer) {
$this->inited = false;
$e = explode(' ', $answer->result);
if (isset($e[1])) {
$ts = new \MongoTimestamp((int) $e[0], (int) $e[1]);
} else {
$ts = new \MongoTimestamp(0, 0);
}
if (\PHPDaemon\Core\Daemon::$config->logevents->value) {
\PHPDaemon\Core\Daemon::log('MongoNode: replication point - ' . $answer->result . ' (' . \PHPDaemon\Core\Debug::dump($ts) . ')');
}
$this->initSlave($ts);
});
}
} elseif (!$this->cursor->session->busy) {
if ($this->cursor->lastOpId !== null) {
$this->cache->set('_rp', $this->cursor->lastOpId);
$this->cursor->lastOpId = null;
}
try {
$this->cursor->getMore();
} catch (\PHPDaemon\Clients\Mongo\ConnectionFinished $e) {
$this->cursor = false;
}
}
}