Example #1
0
    public void postJson(string jsonLevel)
    {
        Debug.Log("Welcome to postJson");
        Debug.Log(jsonLevel);
        string sailsUrl = "https://immense-lake-57494.herokuapp.com/editors";

        Body body = new Body();

        body.userid    = "20";
        body.leveljson = jsonLevel;
        body.createdAt = "2018-10-05 22:00:00";
        body.updatedAt = "2018-10-05 22:00:00";
        string bodyJson = JsonUtility.ToJson(body);

        Dictionary <string, string> parameters = new Dictionary <string, string>();

        parameters.Add("userid", "20");
        parameters.Add("leveljson", jsonLevel);
        parameters.Add("createdAt", "2018-10-05 22:00:00");
        parameters.Add("updatedAt", "2018-10-05 22:00:00");


        //StartCoroutine(_webRequester.PostComplete(sailsUrl, parameters));
        StartCoroutine(_webRequester.PostCompleteConnection(sailsUrl, bodyJson));

        /*  UnityWebRequest resultRequest = _webRequester.Post(sailsUrl, parameters);
         * yield return new WaitUntil(() => resultRequest.isDone);
         * Debug.Log("Error : " + resultRequest.error);
         * Debug.Log("Text : " + resultRequest.downloadHandler.text);*/

        Debug.Log("Bye Bye from postJson");
    }
Example #2
0
    public IEnumerator connectJson()
    {
        string sailsUrl = "https://secure-sands-20186.herokuapp.com/connexion";

        user body = new user();

        body.username = accountInput.text;
        body.password = passwordInput.text;
        string bodyJson = JsonUtility.ToJson(body);

        yield return(StartCoroutine(_webRequester.PostCompleteConnection(sailsUrl, bodyJson)));

        if (token != null)
        {
            loginMenu.SetActive(false);
            mainMenu.SetActive(true);
            if (menuManager)
            {
                StartCoroutine(updateLevels());
            }
        }
    }