Page 1 of 1

How To Cancel an Ongoing Download

Posted: Sun Dec 23, 2012 1:11 am
by endernafi
Hello Dear LiveCoders,

My question is pretty obvious, I think.
Here is my download and feedback procedure:

Code: Select all


on mouseUp
   put the short name of the target into theClickedObject
   switch theClickedObject
      case "cancelTheDownloadButton"
         /* some code to cancel the ongoing download */
         break
   end switch
end mouseUp

on downloadTheBook
   -- a bunch of control statements to decide whether to download the book
   libUrlDownloadToFile theSource, theTarget
   -- checking the file integrity of downloaded book
end downloadTheBook

on urlProgress pUrl, pStatus, pMessage, pTotalSize
   switch
      case pStatus contains "error"
         set the unicodeText of field "feedbackField" to uniEncode(kErrorMessage, "utf8")
         exit to top
         break 
      case pStatus is "contacted"
      case pStatus is "requested"
         set the unicodeText of field "feedbackField" to uniEncode(kStartingMessage, "utf8")
         break
      case pStatus is "loading"
         put (trunc(pMessage / 1024) & "kb / " & trunc(pTotalSize / 1024) & "kb") into field "feedbackField"
         break
      case pStatus is "downloaded"
         put empty into field "feedbackField"
         break
   end switch
end urlProgress

I want to add a cancellation button to give to user the option to cancel the ongoing download.
I absolutely have no idea how to do this :oops:
Could anyone help me to figure this out?


Best,

~ Ender Nafi

Re: How To Cancel an Ongoing Download

Posted: Sun Dec 23, 2012 2:17 am
by Mark
Hi Ender,

Use the unload URL command.

Kind regards,

Mark

Re: How To Cancel an Ongoing Download

Posted: Sun Dec 23, 2012 2:00 pm
by endernafi
Hi Mark,

Thanks for your quick reply,
but unfortunately unload command doesn't support mobile.

From Dictionary:
Platforms: Desktop, Server and Web
Supported Operating Systems: Mac, Windows, Linux
So, is there any workaround?

I'm open to any ideas 8)


Best,

~ Ender Nafi

Re: How To Cancel an Ongoing Download

Posted: Mon Dec 24, 2012 8:46 pm
by Mark
Hi Ender,

I can't find a way to do this in the dictionary and the release notes. It seems there is no way to do it. I wonder what happens if you'd try to use the rreSockets external to close all sockets (or just those on port 80).

Kind regards,

Mark

Re: How To Cancel an Ongoing Download

Posted: Mon Dec 24, 2012 8:50 pm
by endernafi
Hi Mark,

Thanks for all your effort and time, you're great :)
I'll think about rreSockets method.
Btw, I've sent an e-mail to the support team.
I'll post their answer here.


Best,

~ Ender Nafi

Re: How To Cancel an Ongoing Download

Posted: Sat Mar 02, 2013 12:10 pm
by Jellicle
Ender, any answer on this?

Cheers

Gerry

Re: How To Cancel an Ongoing Download

Posted: Sat Mar 02, 2013 12:19 pm
by endernafi
Hi Gerry,

Unfortunately not.
I've spoken to Neil and he said that there's no way to do that as of now :/

My intention was that
the user should hit the back button
and when he/she goes back, the download cancels automatically.
Well, now I use two buttons; one to cancel download and one to go back.
The cancel button's script has exit to top command.
It cancels the download mostly but not reliable.
I have to content myself with this method...


Best,

~ Ender Nafi