Ejemplo n.º 1
0
        public async Task PrefetchChunk(ValorantChunk chunk, CancellationToken cancellationToken)
        {
            var chunkPath = Path.Combine(_chunkDirectory.FullName, chunk.Id + ".valchunk");

            if (File.Exists(chunkPath))
            {
                return;
            }

            using var request  = new HttpRequestMessage(HttpMethod.Get, chunk.Url);
            using var response = await _client.SendAsync(request, cancellationToken).ConfigureAwait(false);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var chunkBytes = await response.Content.ReadAsByteArrayAsync().ConfigureAwait(false);

                await using var fs = new FileStream(chunkPath, FileMode.Create, FileAccess.Write, FileShare.Read);
                await fs.WriteAsync(chunkBytes, 0, chunkBytes.Length, cancellationToken).ConfigureAwait(false);
            }
            #if DEBUG
            else
            {
                var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

                Debugger.Break();
            }
            #endif
        }
Ejemplo n.º 2
0
        public ValorantAPIManifest(BinaryReader reader, DirectoryInfo directoryInfo)
        {
            Id = reader.ReadUInt64();
            var chunks = reader.ReadInt32();

            Chunks = new Dictionary <ulong, ValorantChunk>(chunks);

            for (var i = 0; i < chunks; i++)
            {
                var chunk = new ValorantChunk(reader);
                Chunks.Add(chunk.Id, chunk);
            }

            Paks = reader.ReadTArray(() => new ValorantPak(reader));

            _client = new HttpClient(new HttpClientHandler
            {
                UseProxy                       = false,
                UseCookies                     = false,
                AutomaticDecompression         = DecompressionMethods.All,
                CheckCertificateRevocationList = false,
                PreAuthenticate                = false,
                MaxConnectionsPerServer        = 1337
            });
            _chunkDirectory = directoryInfo;
        }