Beispiel #1
0
    public IEnumerator Get <T>(string https, Dictionary <string, string> mapData, IWebRequestCallBack <T> callBack)
    {
        string data = "";

        if (mapData != null && mapData.Count != 0)
        {
            data += "?";
            foreach (var itemData in mapData)
            {
                data += (itemData.Key + "=" + itemData.Value + "&");
            }
        }

        UnityWebRequest webRequest = UnityWebRequest.Get(https + data);

        yield return(webRequest.SendWebRequest());

        if (webRequest.result == UnityWebRequest.Result.ProtocolError || webRequest.result == UnityWebRequest.Result.ConnectionError)
        {
            callBack.WebRequestGetFail(https, webRequest.error);
        }
        else
        {
            callBack.WebRequestGetSuccess(https, JsonUtil.FromJson <T>(webRequest.downloadHandler.text));
        }
    }
Beispiel #2
0
    public IEnumerator Post <T>(string https, WWWForm form, IWebRequestCallBack <T> callBack)
    {
        UnityWebRequest webRequest = UnityWebRequest.Post(https, form);

        yield return(webRequest.SendWebRequest());

        if (webRequest.result == UnityWebRequest.Result.ProtocolError || webRequest.result == UnityWebRequest.Result.ConnectionError)
        {
            callBack.WebRequestGetFail(https, webRequest.error);
        }
        else
        {
            callBack.WebRequestGetSuccess(https, JsonUtil.FromJson <T>(webRequest.downloadHandler.text));
        }
    }