Network request

I’m using multiple network requests and network download requests to perform http POST and Get. 

I have to send a message using POST http request and after sometime download the data at a website using GET request. I have to send the GET request to download the response until I find some required messages by parsing the xml file. And the process repeats multiple times. 

I’m not able to implement the above because the network listeners associated to each of these requests are delayed. How to ensure that the following lines of code will execute only after the network listener of the first network request is done?

You have to nest your calls.

When your post completes, it will call its network listener function. at that point, you will know it’s complete. You can then make your GET call inside that function.

You could optionally setup polling using a timer to call the GET request every few seconds, but this will be hard on your server and could be interpreted as a DOS attack.

Another technique would have the server generate a push notification to your app when the upload is complete to let you know you need to download the new file. This is a bit of work to setup, but if app user A uploads the file and app user B is needing to know the file was updated so it can sync the download, then this is the practical way. If it’s only app user A checking to see if App user A finished uploading the file, I’m not sure why you even need to download it since you just uploaded it, but the first scenario will work.

Rob

You have to nest your calls.

When your post completes, it will call its network listener function. at that point, you will know it’s complete. You can then make your GET call inside that function.

You could optionally setup polling using a timer to call the GET request every few seconds, but this will be hard on your server and could be interpreted as a DOS attack.

Another technique would have the server generate a push notification to your app when the upload is complete to let you know you need to download the new file. This is a bit of work to setup, but if app user A uploads the file and app user B is needing to know the file was updated so it can sync the download, then this is the practical way. If it’s only app user A checking to see if App user A finished uploading the file, I’m not sure why you even need to download it since you just uploaded it, but the first scenario will work.

Rob