コード例 #1
0
        IEnumerator GetExpositions(OnResponseCallback response = null)
        {
            string uri = URL_API + url_exposition_api + "getExpositions.php";

            string message = "";

            using (UnityWebRequest webRequest = UnityWebRequest.Get(uri))
            {
                // Request and wait for the desired page.
                yield return(webRequest.SendWebRequest());

                if (webRequest.responseCode < 400)
                {
                    message = "";
                }
                else if (webRequest.responseCode >= 400 && webRequest.responseCode < 500)
                {
                    message = "Charlas no encontradas";
                }

                if (webRequest.isNetworkError)
                {
                    Debug.Log(": Error: " + webRequest.error);
                    if (response != null)
                    {
                        response(false, message);
                    }
                }
                else
                {
                    FillConferenceData(webRequest.downloadHandler.text, response);
                }
            }
        }
コード例 #2
0
        private void FillConferenceData(string data, OnResponseCallback response = null)
        {
            var n = JSON.Parse(data);
            //Debug.Log(n);
            List <Exposition> arrExpo = new List <Exposition>();

            for (int i = 0; i < n["message"].Count; i++)
            {
                Exposition e = new Exposition();

                e.id                  = n["message"][i]["id"].AsInt;
                e.date                = DateTime.Parse(n["message"][i]["date"].Value);
                e.name_exposition     = n["message"][i]["name_exposition"].Value;
                e.info_exposition     = n["message"][i]["info_exposition"].Value;
                e.hour                = n["message"][i]["hour"].Value;
                e.room                = n["message"][i]["room"].Value;
                e.name_expositor      = n["message"][i]["name_expositor"].Value;
                e.url_photo_expositor = n["message"][i]["photo_expositor"].Value;
                e.info_expositor      = n["message"][i]["info_expositor"].Value;

                arrExpo.Add(e);
            }

            ConferenceControl.Instance.FillExpositionsInformation(arrExpo);

            if (response != null)
            {
                response(true, "Datos cargado correctamente");
            }
        }
コード例 #3
0
        public void addLike(int idExpo, OnResponseCallback response = null)
        {
            WWWForm form = new WWWForm();

            form.AddField("user_id", AppManager.Instance.currUser.id);
            form.AddField("expo_id", idExpo);

            string url = URL_API + url_user_api + "addLike.php";

            StartCoroutine(PostLibrary(form, url, response));
        }
コード例 #4
0
        IEnumerator Register(string email, OnResponseCallback response = null)
        {
            WWWForm form = new WWWForm();

            form.AddField("email", email);

            string url = URL_API + url_user_api + "register.php";

            using (UnityWebRequest www = UnityWebRequest.Post(url, form))
            {
                yield return(www.SendWebRequest());

                string message = "";

                if (www.responseCode < 400)
                {
                    message = "";
                }
                else if (www.responseCode >= 400 && www.responseCode < 500)
                {
                    message = "El usuario ingresado ya existe";
                }
                else
                {
                    message = "Problemas en el servidor. Intente nuevamente";
                }

                if (www.isNetworkError || www.isHttpError)
                {
                    Debug.Log(www.error);

                    if (response != null)
                    {
                        response(false, message);
                    }
                }
                else
                {
                    //Debug.Log(www.downloadHandler.text);

                    FillUserData(www.downloadHandler.text);

                    if (response != null)
                    {
                        response(true, message);
                    }
                }
            }
        }
コード例 #5
0
        IEnumerator GetUser(string email, OnResponseCallback response = null)
        {
            string uri = URL_API + url_user_api + "getUser.php?email=" + email;

            string message = "";

            using (UnityWebRequest webRequest = UnityWebRequest.Get(uri))
            {
                // Request and wait for the desired page.
                yield return(webRequest.SendWebRequest());

                if (webRequest.responseCode < 400)
                {
                    message = "";
                }
                else if (webRequest.responseCode >= 400 && webRequest.responseCode < 500)
                {
                    message = "El usuario no existe";
                }

                if (webRequest.isNetworkError)
                {
                    Debug.Log(": Error: " + webRequest.error);
                    if (response != null)
                    {
                        response(false, message);
                    }
                }
                else
                {
                    //Debug.Log(":\nReceived: " + webRequest.downloadHandler.text);
                    FillUserData(webRequest.downloadHandler.text);

                    if (response != null)
                    {
                        response(true, message);
                    }
                }
            }
        }
コード例 #6
0
        IEnumerator PostLibrary(WWWForm form, string url, OnResponseCallback response = null)
        {
            using (UnityWebRequest www = UnityWebRequest.Post(url, form))
            {
                yield return(www.SendWebRequest());

                string message = "";

                if (www.responseCode < 400)
                {
                    message = "";
                }
                else if (www.responseCode >= 400 && www.responseCode < 500)
                {
                    message = "El usuario ingresado ya existe";
                }
                else
                {
                    message = "Problemas en el servidor. Intente nuevamente";
                }

                if (www.isNetworkError || www.isHttpError)
                {
                    Debug.Log(www.error);

                    if (response != null)
                    {
                        response(false, message);
                    }
                }
                else
                {
                    if (response != null)
                    {
                        response(true, message);
                    }
                }
            }
        }
コード例 #7
0
 public void registerUser(string email, OnResponseCallback response = null)
 {
     StartCoroutine(Register(email, response));
 }
コード例 #8
0
 public void getConferenceData(OnResponseCallback response = null)
 {
     StartCoroutine(GetExpositions(response));
 }
コード例 #9
0
 public void getUserData(string email, OnResponseCallback response = null)
 {
     StartCoroutine(GetUser(email, response));
 }