Interrupting a PUT URL or POST TO URL

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
KimD
Posts: 225
Joined: Wed Jul 08, 2015 5:51 am

Interrupting a PUT URL or POST TO URL

Post by KimD » Tue Feb 16, 2016 4:38 am

I'm writing an app that communicates with an online database.

At one point I'm using the following to check whether the mobile device is able to connect to the internet -
put URL "http://www.google.com" into ccConnCheck
if ccConnCheck is empty then...

At another point I'm using the following to check whether the mobile device is able to make contact with my online database -
post "" to URL "http://mywebsite.com/mywebsite-test-status.php"
put it into ccResponse
If ccResponse <> "Status=Received" then...
Where there is some PhP set up at the other end to respond to the POST.

It all "works", but I'm finding that there is a lot of variation in how quickly these PUT URL and POST TO URL commands are executed. Often it is less than 1 second, but it can take more than 15 seconds.

I'm worried about my users attention span ;-)

I would like to implement a "Cancel" button - something that allows the user to abort the process of waiting for the results of the PUT URL and POST TO URL commands.

I can't think how I'd do this. If I understand correctly then the "standard" way to have a button abort a handler, is to have the button set an AbortNow value, and to insert code to test for the state of the AbortNow value within the handler. But in my case, by the time that I could test for the AbortNow value, after the PUT and POST statements, the wait would already have occurred.

Is there an easy way to do this?

Either that or is it possible to have these commands abort themselves after waiting a fixed period of time (e.g. 5 seconds)?

Thanks in advance.
Last edited by KimD on Mon Feb 22, 2016 10:56 pm, edited 1 time in total.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Interrupting a PUT URL or POST TO URL

Post by jacque » Tue Feb 16, 2016 6:22 pm

Look at the socketTimeoutInterval in the dictionary.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

KimD
Posts: 225
Joined: Wed Jul 08, 2015 5:51 am

Re: Interrupting a PUT URL or POST TO URL

Post by KimD » Wed Feb 17, 2016 5:30 am

Perfect. Seems to be working now. Thanks

Post Reply