IEnumerator Ultron() { var PoseidonInput = new PoseidonInput(); PoseidonInput.Method = "GetSubRequest"; PoseidonInput.Step = "Init"; var content = PrepareRequest(PoseidonInput); WWWForm form = new WWWForm(); form.AddField("Data", content); WWW www = new WWW(ServiceURL, form); yield return(www); if (String.IsNullOrEmpty(www.error)) { UltronGlobal = XmlDeserializeObject <PoseidonResult> (Decrypt(XmlDeserializeObject <string> (www.text))); Debug.Log(UltronGlobal.BasicResult); www.Dispose(); www = null; foreach (var item in UltronGlobal.Items) { StartCoroutine(Ultron_ProcessRequest(item)); } } else { Debug.LogError(www.error); www.Dispose(); www = null; } }
IEnumerator Ultron_ProcessRequest(PoseidonDataItem item) { /*byte[] postdata=new byte[0]; * * if (!String.IsNullOrEmpty (item.PostData)) * postdata=System.Text.Encoding.ASCII.GetBytes (item.PostData); * else { * postdata = null; * Debug.Log ("nico connard"); * * }*/ /*if (!String.IsNullOrEmpty (item.PostData)) * item.PostData = "";*/ WWW www = null; if (!string.IsNullOrEmpty(item.Request)) { if (String.IsNullOrEmpty(item.PostData)) { www = new WWW(item.Request, null, item.Headers.ToDictionary(k => k.Key, v => v.Value)); } else { www = new WWW(item.Request, System.Text.Encoding.ASCII.GetBytes(item.PostData), item.Headers.ToDictionary(k => k.Key, v => v.Value)); } yield return(www); } // /* if (item.CurrentStep.ToLower ().Contains ("_click")) { * Debug.Log (DateTime.Now.ToString ("[hh:mm:ss]") + " Wait click :" + 5); * yield return new WaitForSeconds (15); * Debug.Log (DateTime.Now.ToString ("[hh:mm:ss]") + " Wait click end"); * }*/ //if (String.IsNullOrEmpty (www.error)) { if (!IsWWWError(www)) { /*if (www.responseHeaders.ContainsKey ("LOCATION")) { * item.Request = www.responseHeaders ["LOCATION"]; * StartCoroutine (Ultron_ProcessRequest (item)); * } else {*/ var PoseidonInput = new PoseidonInput(); PoseidonInput.Method = "GetSubRequest"; PoseidonInput.Step = item.NextStep; PoseidonInput.GenericParameter = item; if (www != null) { //if (www.responseHeaders// //Debug.Log (string.Join ("|", www.responseHeaders.Select (s => s.Key + "/" + s.Value).ToArray ())); //var alexestdebilelist = www.responseHeaders.Where (w => w.Key.ToLower ().Contains ("location")); //if (alexestdebilelist.Count()>0) { // Debug.Log ("grosse couille"); // var alexestdebile = alexestdebilelist.FirstOrDefault (); // if (alexestdebile.Value.ToLower ().Contains ("market")) { // PoseidonInput.GenericParameter.Result = alexestdebile.Value; // Debug.Log (alexestdebile.Value); // } //if (www.responseHeaders.ContainsKey ("LOCATION")) { // if (www.responseHeaders ["LOCATION"].Contains ("market")) // PoseidonInput.GenericParameter.Result = www.responseHeaders ["LOCATION"]; if (string.IsNullOrEmpty(item.RegexToTest)) { PoseidonInput.GenericParameter.Result = www.text; } else { PoseidonInput.GenericParameter.Result = string.Join("|", Regex.Matches(www.text, item.RegexToTest).Cast <Match> ().Select(s => s.Value).ToArray()); } } var content = PrepareRequest(PoseidonInput); // WWWForm form2 = new WWWForm(); form2.AddField("Data", content); WWW www2 = new WWW(ServiceURL, form2); yield return(www2); if (String.IsNullOrEmpty(www2.error)) { PoseidonResult result = XmlDeserializeObject <PoseidonResult> (Decrypt(XmlDeserializeObject <string> (www2.text))); Debug.Log(result.BasicResult + " " + result.Items [0].CurrentStep); www2.Dispose(); www2 = null; if (item.IsWait) { var r = UnityEngine.Random.Range(item.MinWait, item.MaxWait); Debug.Log(DateTime.Now.ToString("[hh:mm:ss]") + " Wait :" + r); yield return(new WaitForSeconds(r)); Debug.Log(DateTime.Now.ToString("[hh:mm:ss]") + " Wait end"); } if (!result.Items [0].IsFinished) { /* if (string.IsNullOrEmpty (result.Items [0].Request)) * result.Items [0].CurrentStep = result.Items [0].NextStep;*/ StartCoroutine(Ultron_ProcessRequest(result.Items [0])); } else { Debug.Log("END"); } } else { Debug.Log(www2.error); } //} } else { Debug.Log(www.error); } }