function fetchDetails() { $this->openConnection(); $serverName = $this->connection->getServerName(); if ($serverName != $this->name) { $service = new ServerService(); $service->register($this); $this->name = $serverName; } $info = $this->connection->getSystemInfo(); $this->login = $info->serverLogin; $this->titleId = $info->titleId; $this->joinIp = $info->publishedIp; $this->joinPort = $info->port; $this->joinPassword = $this->connection->getServerPassword(); $this->specPassword = $this->connection->getServerPasswordForSpectator(); $this->isRelay = $this->connection->isRelayServer(); $this->connection = $this->connection; }
function onInit() { $config = \ManiaLive\DedicatedApi\Config::getInstance(); $this->connection = Connection::factory($config->host, $config->port, $config->timeout, $config->user, $config->password); $this->serverStatus = $this->connection->getStatus(); $players = $this->connection->getPlayerList(-1, 0); foreach ($players as $player) { try { $details = $this->connection->getDetailedPlayerInfo($player->login); foreach ($details as $key => $value) { if ($value) { $player->{$key} = $value; } } if ($player->spectatorStatus % 10 == 0) { $this->players[$player->login] = $player; } else { $this->spectators[$player->login] = $player; } } catch (\Exception $e) { } } try { $this->maps = $this->connection->getMapList(-1, 0); $this->currentMap = $this->connection->getCurrentMapInfo(); if (isset($this->maps[$this->connection->getNextMapIndex()])) { $this->nextMap = $this->maps[$this->connection->getNextMapIndex()]; } else { $this->nextMap = null; } } catch (\Exception $e) { $this->maps = array(); $this->nextMap = null; $this->currentMap = null; } $this->server = $this->connection->getServerOptions(); $this->gameInfos = $this->connection->getCurrentGameInfo(); try { $this->serverLogin = $this->connection->getSystemInfo()->serverLogin; } catch (\Exception $e) { $this->serverLogin = null; } }