PHPDaemon\Examples\GameMonitor::updateAllServers PHP Method

updateAllServers() public method

public updateAllServers ( )
    public function updateAllServers()
    {
        gc_collect_cycles();
        $app = $this;
        $amount = 1000 - sizeof($this->jobMap);
        \PHPDaemon\Core\Daemon::log('amount: ' . $amount);
        if ($amount <= 0) {
            return;
        }
        $this->servers->find(function ($cursor) use($app, $amount) {
            if (isset($cursor->items[0]['$err'])) {
                \PHPDaemon\Core\Daemon::log(\PHPDaemon\Core\Debug::dump($cursor->items));
                return;
            }
            foreach ($cursor->items as $server) {
                $app->updateServer($server);
            }
            $cursor->destroy();
        }, ['where' => ['$or' => [['atime' => ['$lte' => time() - 30], 'latency' => ['$ne' => false]], ['atime' => ['$lte' => time() - 120], 'latency' => false], ['atime' => null]]], 'limit' => -max($amount, 100), 'sort' => ['atime' => 1]]);
    }