hch
18 小时以前 8e91ea34abd99ec2960f67580baf2133dc86799f
Main/Utility/HttpRequestEx.cs
@@ -9,42 +9,37 @@
    //回合战报
    public static void UnityWebRequestTurnFightGet(string _url, string guid, int timeout = 5, Action<bool, string, byte[]> _result = null)
    public static void UnityWebRequestTurnFightGet(string _url, string guid, int mapID, int timeout = 5, Action<bool, string, int, byte[]> _result = null)
    {
        GetTurnFightData(_url, guid, timeout, _result).Forget();
        GetTurnFightData(_url, guid, mapID, timeout, _result).Forget();
    }
    static async UniTask GetTurnFightData(string remoteURL, string guid, int timeout, Action<bool, string, byte[]> _result = null)
    static async UniTask GetTurnFightData(string remoteURL, string guid, int mapID, int timeout, Action<bool, string,int, byte[]> _result = null)
    {
        UnityWebRequest request = UnityWebRequest.Get(remoteURL);
        request.timeout = timeout;
        try
        {
            UnityWebRequest request = UnityWebRequest.Get(remoteURL);
            request.timeout = timeout;
            await request.SendWebRequest();
            if (request.isDone)
            {
                if (request.result == UnityWebRequest.Result.Success)
                {
                    _result(true, guid, request.downloadHandler.data);
                    _result(true, guid, mapID, request.downloadHandler.data);
                }
                else
                {
                    Debug.LogError("GetDataBEx 失败 " + request.result.ToString());
                    _result(false, guid, null);
                    _result(false, guid, mapID, null);
                }
            }
        }
        catch (Exception ex)
        {
            _result(false, guid, null);
            _result(false, guid, mapID, null);
            Debug.LogError($"GetDataBEx 异常 - URL: {remoteURL}, Exception: {ex.Message}");
        }
        finally
        {
            request.Dispose();
        }
    }