IEnumerator RegisterAccount() { GameObject phd = (GameObject)Instantiate(Resources.Load("HttpData/PostHttpData")); PostHttpData postHttpData = phd.GetComponent <PostHttpData>(); WWWForm form = new WWWForm(); form.AddField("username", Username.GetComponent <InputField>().text); form.AddField("password1", Password1.GetComponent <InputField>().text); form.AddField("password2", Password2.GetComponent <InputField>().text); postHttpData.PostData(ServerURL.BaseUrl + "rest-auth/registration/", form); // 서버로부터 메시지 기다림 yield return(StartCoroutine(WaitMessage(postHttpData, 7.0f))); string msg = postHttpData.getMessage(); if (postHttpData.getErrorMessage() != postHttpData.DefaultErrorMessage) { Msg.text = msg; } if (postHttpData.getErrorMessage() == postHttpData.DefaultErrorMessage && postHttpData.getMessage() != postHttpData.DefaultMessage) { yield return(StartCoroutine(RegisterUserList())); SignUpObj.SetActive(false); LoginObj.SetActive(true); } }
IEnumerator LogIn() { GameObject phd = (GameObject)Instantiate(Resources.Load("HttpData/PostHttpData")); PostHttpData postHttpData = phd.GetComponent <PostHttpData>(); WWWForm form = new WWWForm(); form.AddField("username", Username.GetComponent <InputField>().text); form.AddField("password", Password.GetComponent <InputField>().text); postHttpData.PostData(ServerURL.BaseUrl + "rest-auth/login/", form); // 서버로부터 메시지 기다림 yield return(StartCoroutine(WaitMessage(postHttpData, 7.0f))); string msg = postHttpData.getMessage(); if (postHttpData.getErrorMessage() != postHttpData.DefaultErrorMessage) { Msg.text = msg; } if (postHttpData.getErrorMessage() == postHttpData.DefaultErrorMessage && postHttpData.getMessage() != postHttpData.DefaultMessage) { PlayerPrefs.SetString("Token", JsonUtility.FromJson <TokenData>(msg).key); Debug.Log(PlayerPrefs.GetString("Token")); LoginObj.SetActive(false); sc.TurnToMainMenu(); } }
IEnumerator RegisterUserList() { GameObject phd = (GameObject)Instantiate(Resources.Load("HttpData/PostHttpData")); PostHttpData postHttpData = phd.GetComponent <PostHttpData>(); WWWForm form = new WWWForm(); form.AddField("ID", Username.GetComponent <InputField>().text); postHttpData.PostData(ServerURL.BaseUrl + "users/", form); yield return(new WaitForSeconds(1.0f)); }
IEnumerator RegisterRecord() { GameObject phd = (GameObject)Instantiate(Resources.Load("HttpData/PostHttpData")); PostHttpData postHttpData = phd.GetComponent <PostHttpData>(); WWWForm form = new WWWForm(); form.AddField("Stage", stage); form.AddField("Score", score); postHttpData.PostData(ServerURL.BaseUrl + "records/", form); yield return(new WaitForSeconds(2.0f)); yield return(StartCoroutine(ConfirmRecords())); }
IEnumerator LogOut() { GameObject phd = (GameObject)Instantiate(Resources.Load("HttpData/PostHttpData")); PostHttpData postHttpData = phd.GetComponent <PostHttpData>(); WWWForm form = new WWWForm(); postHttpData.PostData(ServerURL.BaseUrl + "rest-auth/logout/", form); // 서버로부터 메시지 기다림 yield return(StartCoroutine(WaitMessage(postHttpData, 5.0f))); if (postHttpData.getErrorMessage() == postHttpData.DefaultErrorMessage && postHttpData.getMessage() != postHttpData.DefaultMessage) { Debug.Log("Token(Before): " + PlayerPrefs.GetString("Token")); PlayerPrefs.SetString("Token", ""); Debug.Log("Token(After): " + PlayerPrefs.GetString("Token")); } }