/** * @param ReplayInterface $replay * @param int $chunkId * @param int $tries * * @return mixed * * @throws GameNotStartedException */ public function getLastChunkInfos(ReplayInterface $replay, $chunkId = 30000, $tries = 0) { $lastInfos = json_decode($this->client->getLastChunkInfo($replay->getRegion(), $replay->getGameId(), $chunkId), true); if (0 === $lastInfos['chunkId']) { if ($tries > 10) { throw new GameNotStartedException('The game is not started'); } sleep(30); return $this->getLastChunkInfos($replay, $chunkId, $tries + 1); } return $lastInfos; }
/** * @param ReplayInterface $replay * @param int $chunkId * @param int $tries * * @return mixed * * @throws GameNotStartedException */ public function getLastChunkInfos(ReplayInterface $replay, $chunkId = 30000, $tries = 0) { $lastInfos = json_decode($this->client->getLastChunkInfo($replay->getRegion(), $replay->getGameId(), $chunkId), true); if (false === $lastInfos || !isset($lastInfos['chunkId']) || 0 === $lastInfos['chunkId']) { if (false === $lastInfos || !isset($lastInfos['chunkId'])) { $replay->addDownloadRetry(); if ($this->options['replay.download.retry'] == $replay->getDownloadRetry()) { return false; } } elseif (0 === $lastInfos['chunkId']) { if ($tries > 10) { throw new GameNotStartedException('The game is not started'); } sleep(29); // 29 + 1 below } sleep(1); return $this->getLastChunkInfos($replay, $chunkId, $tries + 1); } // Clear retries $replay->resetDownloadRetry(); return $lastInfos; }