Hello everyone, I need your help.
Simple task: when user push the button, we need to send GET request to server(response is not necessary).
The next code is working on the computer, but is not working on the Android.
public void Send(string arg)
{
WebRequest request = WebRequest.Create("http://x.x.x.x/server/?value=" + arg);
DoWithResponse(request, (response) => {
var body = new StreamReader(response.GetResponseStream()).ReadToEnd();
Debug.Log(body);
});
}
void DoWithResponse(WebRequest request, Action<HttpWebResponse> responseAction)
{
Action wrapperAction = () =>
{
request.BeginGetResponse(new AsyncCallback((iar) =>
{
var response = (HttpWebResponse)((HttpWebRequest)iar.AsyncState).EndGetResponse(iar);
responseAction(response);
}), request);
};
wrapperAction.BeginInvoke(new AsyncCallback((iar) =>
{
var action = (Action)iar.AsyncState;
action.EndInvoke(iar);
}), wrapperAction);
}
How can I resolve this?