Exemple #1
0
    private IEnumerator WaitAndSend()
    {
        CR_running = true;
        yield return(new WaitForSeconds(cooldownBeforeSend));

        string json = JsonUtility.ToJson(eventsJSON);

        print(json);
        CustomPlayerPrefs.SetString("eventsJSON", json);

        try
        {
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(serverUrl);
            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                streamWriter.Write(json);
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                if (httpResponse.StatusCode == HttpStatusCode.OK)
                {
                    eventsJSON.events.Clear();
                    CR_running = false;
                    CustomPlayerPrefs.DeleteKey("eventsJSON");
                }
                else
                {
                    coroutine = WaitAndSend();
                    StartCoroutine(coroutine);
                }
            }
        }
        catch (Exception ex)
        {
            coroutine = WaitAndSend();
            StartCoroutine(coroutine);
        }
    }
Exemple #2
0
 protected void ClearContinueData()
 {
     Log.Debug("ClearContinueData");
     CustomPlayerPrefs.DeleteKey(CONTINUE_KEY);
 }