Hi Guys, Player of my game say me they got a problem when they play on the subway and the connection didn't work properly. I send request WWW form to my script php and the response is wrong. Like this: WWWForm form = new WWWForm(); form.AddField("field1", field1); WWW w = new WWW(URL, form); yield return w; if (w.error != null) { Txt1.text = "Connection problem. Please check your internet connection."; } else { JsonData json = JsonMapper.ToObject(w.text); if (json["return"].ToString() == "ok") { //do the job } else { print("Problem."); print(w.text); } w.Dispose(); } I tried when disable internet manually its work perfectly, but when they are on the subway they got no answer. What you think of checking www.responseHeaders to know if internet is ok or not? How you test your internet connectivity on the subway ? TY
When you're checking for an error don't use: Code (CSharp): if( w.error != null ) as it doesn't cover all the cases, especially on mobile platforms. You need to use Code (CSharp): if (!string.IsNullOrEmpty(w.error)) { // An error has occurred } else { // No error has occurred } This is because w.error may not be null but it might be empty (which is ok and not an error). The only true way to check internet connectivity is the way you're doing it (by trying to access a site). Having wifi or mobile data availability isn't a good test as you can't actually tell until you try to access a site.
Hi, i tested myself on subway with: if (!string.IsNullOrEmpty(w.error)) I got the same result if you have another idea to fix this will be great. TY