public async void Login() { var send = new KeyValueProtocol(); send["username"] = Input("username").text; if (Input("password").text == PlayerPrefs.GetString("lastLoginToken")) { send["loginToken"] = Input("password").text; send["cmd"] = "loginByToken"; } else { send["password"] = StringTool.MD5(Input("password").text); send["cmd"] = "login"; } var receive = await DataHttpClient.PostAsync(DataServerUrl, send); if (receive["status"] == "成功") { PlayerPrefs.SetString("lastUsername", receive["username"]); PlayerPrefs.SetString("lastLoginToken", receive["loginToken"]); username = send["username"]; loginToken = receive["loginToken"]; UnityEngine.SceneManagement.SceneManager.LoadScene("Main"); } else { IDGUI.Log(receive["info"]); Input("username").text = ""; Input("password").text = ""; } }
public bool Success(KeyValueProtocol receive) { if (receive["status"] == "成功") { return(true); } else { IDGUI.Log(receive["info"]); return(false); } }
public async void Register() { var send = new KeyValueProtocol(); send["username"] = Input("username").text; send["password"] = StringTool.MD5(Input("password").text); send["cmd"] = "register"; var receive = await DataHttpClient.PostAsync(DataServerUrl, send); if (receive["status"] == "成功") { Login(); } else { IDGUI.Log(receive["info"]); Input("username").text = ""; Input("password").text = ""; } }