Page 1 of 1

Post to URL and the case of resetall

Posted: Mon Jun 10, 2013 3:01 pm
by bangkok
I have a button that posts some data to a web server with a LiveCode Server script, this script then returns some data.

If I click several times, too fast, things aren't working anymore. No data returned.

I have to issue a resetall command, or quit the stack.

If I just close the socket (i've tried), it doesn't seem enough.

So my questions is :
-if i want to avoid any trouble what should I do ? Disable the button at the begining, so the user can't click several times ?

Re: Post to URL and the case of resetall

Posted: Mon Jun 10, 2013 5:24 pm
by Mark
Hi,

Her eis something to test:

Code: Select all

local lBusy
on mouseUp
   put empty
   if lBusy is true then
      beep
      answer "Are you sure" with "Yes" or "No"
      if it is "No" then
         exit mouseUp
      else
         repeat for each line mySock in the openSockets
            close socket mySock
         end repeat
         beep
      end if
   end if
   put true into lBusy
   put  "http://bla.bla.com" into myUrl
   post "hello" to url myUrl
   put the result into rslt
   put false into lBusy
   put "ok" & rslt
end mouseUp
If you double-click on a button with this script, it will ask you if you really want that and if you do, it will close all sockets before continuing. Make sure to sue an existing URL (not bla.bla.com and not google.com).

Best,

Mark

Re: Post to URL and the case of resetall

Posted: Tue Jun 11, 2013 7:40 am
by bangkok
Thanks Mark for your idea.

I found another turn around : to disable the button (disable me) and then enable it at the end.

That way, if the user clicks like a crazy person, the POST operation is not blocked/jammed.

Re: Post to URL and the case of resetall

Posted: Tue Jun 11, 2013 9:14 am
by Mark
Hi,

As I said, that's a bad idea :-) If something goes wrong, the button is disabled and the user can't use your software anymore until he restarts it.

Best,

Mark