Post to URL and the case of resetall

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Post to URL and the case of resetall

Post by bangkok » Mon Jun 10, 2013 3:01 pm

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 ?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Post to URL and the case of resetall

Post by Mark » Mon Jun 10, 2013 5:24 pm

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Post to URL and the case of resetall

Post by bangkok » Tue Jun 11, 2013 7:40 am

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.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Post to URL and the case of resetall

Post by Mark » Tue Jun 11, 2013 9:14 am

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply