Hi I am learning how to post data to server-side code with SSL. I am using the following code :
using UnityEngine;
using System.Collections;
public class Main : MonoBehaviour {
public GUIText textbox;
private string message;
private float timeElapsed;
private string url;
private int displayWait = 10;
private float totalTimeUsed;
private float totalCalled;
void Start () {
message = "";
totalTimeUsed = 0f;
totalCalled = 0f;
url = "https://mywebsite/echoname.aspx";
}
void Update()
{
if ( message=="")
{
timeElapsed = Time.time;
message = "waiting";
Debug.Log("sent request");
StartCoroutine(retrieve());
}
else if ( message=="waiting" )
{
// do nothing
}
else
{
displayWait -= 1;
if ( displayWait <= 0 )
{
displayWait = 10;
message = "";
}
Debug.Log("---");
}
}
IEnumerator retrieve()
{
var form = new WWWForm();
form.AddField( "name", Random.Range(0,100) );
WWW download = new WWW(url , form );
yield return download;
if ( download.error!=null ) {
message = "error : " + download.error;
}
else
{
totalTimeUsed += (Time.time - timeElapsed);
totalCalled += 1;
message = "ok : " + download.text + ",
time used : " + (Time.time - timeElapsed).ToString() + ",
average : " + (totalTimeUsed/totalCalled).ToString();
textbox.text = message;
Debug.Log("received request");
}
}
}
Interesting thing is, the elapse time on each https call is 3 about times slower in Android, in compare to iOS, on the same WIFI network, please see the attached screenshots.
Is it purely caused by the phone hardware or something to do with my code? Thanks.
Regards,
Alex