Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Network request
Started by rjg7712 Nov 28 2018 04:21 PM

1 reply to this topic
asynchronous http request network request network download
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

rjg7712

[GLOBAL: userInfoPane.html]
rjg7712
  • Observer

  • 2 posts
  • Corona SDK

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?



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,997 posts
  • Corona SDK

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




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: asynchronous http request, network request, network download