// Calling the API and Getting response
    public IEnumerator CallAPIProcess(Action <Block_DataModel[]> outcome)
    {
        // WWWForm form = new WWWForm();
        //UnityWebRequest rq = UnityWebRequest.Post(WEB_URL, form);
        UnityWebRequest rq = UnityWebRequest.Get(WEB_URL);

        {
            yield return(rq.SendWebRequest());

            // rq.downloadHandler.text;
            //  Debug.Log(rq.downloadHandler.text);
            // string jsonResult = System.Text.Encoding.UTF8.GetString(rq.downloadHandler.data);
            string jsonResult = System.Text.Encoding.UTF8.GetString(rq.downloadHandler.data);
            // Debug.Log(jsonResult);

            EtherScanAPIReply_Model data = JsonUtility.FromJson <EtherScanAPIReply_Model>(jsonResult);
            if (data == null)
            {
                Debug.LogError($"Null data. Response code: {rq.responseCode}.");
                yield return(new WaitForSeconds(delayBetweenEachFailedAttempt));

                consol.text = "INVALID API REPLY, RETRYING..";
                flo         = 0; lerptime = 0;
                StartCoroutine(CallAPIProcess(outcome));
                yield break;
            }
            outcome?.Invoke(data.result);
            consol.text = "LIVE PING ON ETH-RINKEBY TESTNET";
            //consol.text = "LIVE PING ON ETHEREUM MAINNET";
            lerptime = 0; flo = 1;
            //Debug.Log("Live Ping on Ethereum MainNet");
        }
    }
    public IEnumerator CallAPIProcessTxDetail(Action <Block_DataModel[]> outcome)
    {
        UnityWebRequest rq = UnityWebRequest.Get(WEB_URL);
        {
            yield return(rq.SendWebRequest());

            string jsonResult = System.Text.Encoding.UTF8.GetString(rq.downloadHandler.data);
            Debug.Log(jsonResult);

            EtherScanAPIReply_Model data = JsonUtility.FromJson <EtherScanAPIReply_Model>(jsonResult);
            if (data == null)
            {
                Debug.LogError($"Null data. Response code: {rq.responseCode}.");
                yield return(new WaitForSeconds(2));

                // consol.text = "INVALID API REPLY, RETRYING..";

                StartCoroutine(CallAPIProcessTxDetail(outcome));
                yield break;
            }
            outcome?.Invoke(data.result);
        }
    }
Example #3
0
    // Calling the API and Getting response
    public IEnumerator CallAPIProcess(Action <Block_DataModel[]> outcome)
    {
        UnityWebRequest rq = UnityWebRequest.Get(WEB_URL);
        {
            yield return(rq.SendWebRequest());

            // rq.downloadHandler.text;
            //  Debug.Log(rq.downloadHandler.text);
            string jsonResult = System.Text.Encoding.UTF8.GetString(rq.downloadHandler.data);

            EtherScanAPIReply_Model data = JsonUtility.FromJson <EtherScanAPIReply_Model>(jsonResult);

            if (data == null)
            {
                Debug.LogError($"Null data. Response code: {rq.responseCode}.");
                yield return(new WaitForSeconds(delayBetweenEachFailedAttempt));

                StartCoroutine(CallAPIProcess(outcome));
                yield break;
            }

            outcome?.Invoke(data.result);
        }
    }