Hello,
I made those functions that call a php file and return data,
but i’m unable to make the script wait for the request to end.
So is there a way to make a www request without Coroutine or yield it ?
Can we make a function in Csharp that make a www request and return the result (best: available using static call :p) ?
Thanks.
public IEnumerator MakeRequest(string HandlerFile ,Hashtable RequestParams)
{
WWWForm RequestForm = new WWWForm();
Crypt NewCrypt = new Crypt(key,iv);
foreach(DictionaryEntry Param in RequestParams)
{
RequestForm.AddField( Param.Key.ToString(), NewCrypt.Encrypt(Param.Value.ToString()) );
}
WWW w = new WWW(CoreUrl + HandlerFile, RequestForm);
yield return w;
if (w.error != null)
{ RequestedData = null; Debug.Log(w.error); }
else
{
RequestedData = NewCrypt.Decrypt(w.text);
w.Dispose();
}
}
public string Request(string Handler ,Hashtable RequestParams)
{
if(CoreHandlers.ContainsKey(Handler))
{
yield StartCoroutine(MakeRequest(CoreHandlers[Handler], RequestParams));
return RequestedData;
}
else
{
print("Error : Unknown Handler");
return null;
}
}