AxibugEmuOnline/AxibugEmuOnline.Client.Switch/Assets/Script/AppMain/AxiHttp/AxiHttpTest.cs
2025-10-07 19:57:45 +08:00

52 lines
1.6 KiB
C#

using System;
using System.Collections;
using UnityEngine;
public class AxiHttpTest : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.T))
{
//for (int i = 0; i < 1000; i++)
StartCoroutine(DownloadFromURL("http://emu.axibug.com/UserSav/12/Nes/190/1/1.sav", "D:/1.bin", null));
}
}
IEnumerator DownloadFromURL(string url, string path, Action<byte[]> callback)
{
for (int i = 0; i < 1000; i++)
{
AxiHttpProxy.SendDownLoadProxy request = AxiHttpProxy.GetDownLoad(url);
while (!request.downloadHandler.isDone)
{
Debug.Log($"下载进度:{request.downloadHandler.downLoadPr} ->{request.downloadHandler.loadedlenght}/{request.downloadHandler.needdownloadLenght}");
yield return null;
}
AxiHttpProxy.ShowAxiHttpDebugInfo(request.downloadHandler);
Debug.Log($"下载进度完毕:data.Length=>" + request.downloadHandler.data.Length);
}
//if (!request.downloadHandler.bHadErr)
//{
// AxiIO.Directory.CreateDirectory(path);
// AxiIO.File.WriteAllBytes($"{path}/{url.GetHashCode()}", request.downloadHandler.data, false);
// callback?.Invoke(request.downloadHandler.data);
//}
//else
//{
// callback?.Invoke(null);
//}
}
}