IEnumerator Register()
{
this.SetBeginRegisterState();
string _userName = this.Input_User.text;
string _password = this.Input_Password.text;
string _path = Global.RegisterAndLoginUrl + "register.aspx?" +
"passport=" + _userName +
"&password=" + _password +
"&os=" + CommonFunctions.TransferrUrl(SystemInfo.operatingSystem) +
"&deviceId=" + CommonFunctions.TransferrUrl(SystemInfo.deviceUniqueIdentifier) +
"&deviceName=" + CommonFunctions.TransferrUrl(SystemInfo.deviceName);
WWW _www = new WWW(_path);
yield return _www;
if (_www.error != null)
{
this.SetEndRegisterState();
Global.ShowPromptWindow(CommonFunctions.GetErrorDescription(_www.error));
}
else
{
WWWValue _result = new WWWValue(true, Encoding.UTF8.GetString(_www.bytes));
if (_result.Success)
{
Global.PlayerId = _result.GetValue(0);
StartCoroutine(this.Login());
}
else
{
this.SetEndRegisterState();
Global.ShowPromptWindow(CommonFunctions.GetErrorDescription(_result.ErrorCode));
}
}
{
this.SetBeginRegisterState();
string _userName = this.Input_User.text;
string _password = this.Input_Password.text;
string _path = Global.RegisterAndLoginUrl + "register.aspx?" +
"passport=" + _userName +
"&password=" + _password +
"&os=" + CommonFunctions.TransferrUrl(SystemInfo.operatingSystem) +
"&deviceId=" + CommonFunctions.TransferrUrl(SystemInfo.deviceUniqueIdentifier) +
"&deviceName=" + CommonFunctions.TransferrUrl(SystemInfo.deviceName);
WWW _www = new WWW(_path);
yield return _www;
if (_www.error != null)
{
this.SetEndRegisterState();
Global.ShowPromptWindow(CommonFunctions.GetErrorDescription(_www.error));
}
else
{
WWWValue _result = new WWWValue(true, Encoding.UTF8.GetString(_www.bytes));
if (_result.Success)
{
Global.PlayerId = _result.GetValue(0);
StartCoroutine(this.Login());
}
else
{
this.SetEndRegisterState();
Global.ShowPromptWindow(CommonFunctions.GetErrorDescription(_result.ErrorCode));
}
}
}
www传输的时候 如果不对特殊字符进行转义的话,打包到Android或IOS平台上去会出错,因此要进行一下替换
#region WWW相关
public static string TransferrUrl(string _content)
{
_content = _content.Replace("<", "");
_content = _content.Replace(">", "");
_content = _content.Replace(" ", "");
_content = _content.Replace("/", "");
_content = _content.Replace("-", "");
_content = _content.Replace("(", "");
_content = _content.Replace(")", "");
return _content;
}
#endregion