using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
namespace MuHua {
///
/// Get请求数据
///
public class DataRequestGet : DataRequest {
public readonly string url;
public Action OnError;
public Action OnCallback;
public override string Url => url;
public override WebRequestType RequestType => WebRequestType.GET;
/// Web Get请求数据
public DataRequestGet(string url, Action OnCallback = null) {
this.url = url;
this.OnCallback = OnCallback;
}
public override void RequestResultHandle(bool isDone, UnityWebRequest web) {
DownloadHandler downloadHandler = web.downloadHandler;
if (!isDone) { OnError?.Invoke(downloadHandler.text); return; }
OnCallback?.Invoke(downloadHandler.text);
}
}
}