libURLSetStatusCallback | ||||||||||
Type | command | |||||||||
Dictionary | LCS | |||||||||
Library | LiveCode Script | |||||||||
Syntax |
| |||||||||
Associations | internet library | |||||||||
Summary | Sets up a callback message to be sent periodically during uploads and downloads. | |||||||||
Introduced | 2.0 | |||||||||
OS | mac, windows, linux, web | |||||||||
Platforms | desktop, server | |||||||||
Parameters |
| |||||||||
Example |
| |||||||||
Related | Message: startup, openBackground, preOpenStack, openStack, preOpenCard Library: library, Internet library Keyword: URL, ftp, item, http Control Structure: function, switch Function: URLStatus Command: libURLSetStatusCallback, put, load, group, libURLftpUploadFile, libURLftpUpload, libURLDownloadToFile Glossary: LiveCode custom library, application, standalone application, evaluate, message, URL, callback, command, control structure, main stack, Standalone Application Settings, upload, download, server, HTTP, handler | |||||||||
Security | network | |||||||||
Description | Use the libURLSetStatusCallback command if you want to do periodic tasks (such as updating a progress bar) during a data transfer. The Internet library periodically updates the URLStatus function during uploads and downloads made with the libURLDownloadToFile, libURLftpUpload, libURLftpUploadFile, put, and load commands, as well as downloads triggered by evaluating an ftp or http URL. Whenever the Internet library updates the URLStatus function, it also sends any callback message you've set up with the libURLSetStatusCallback command. Callback messages are sent even during blocking uploads and downloads (such as a download started with the put command), so you can use this method to monitor progress for all file transfers. The callback message is sent with two parameters: the URL and the URL's current status. For example, suppose you execute the following statement to set up a callback message:
Then suppose you begin an upload with the following command:
Periodically while the text of the field is being uploaded to the file, a "myProgress" message is sent to button "Monitor". The first parameter sent with "myProgress" is the URL (in this case, the URL is "ftp://me:mypass@ftp.example.org/myfile"), and the second parameter is the current status of that URL. The "myProgress" handler might look like this:
The URL status parameter is similar to the status returned by the URLStatus function, and is one of the following:
If multiple file transfers are occurring at the same time, a separate callback message is sent for each URL. If you want your callback handler to treat URLs differently (for example, if you want to display separate progress bars for different URLs, or do one thing with http URLs and something else with ftp URLs), use a switch control structure in the handler. You cannot have two callback messages set up at the same time for uploads and downloads. If you use the libURLSetStatusCallback command to set up a callback message, the Internetlibrary forgets any callback message you previously set up with the command. To turn off the callback message, use the following statement:
If you don't include the messageName and objectLongID parameters, the libURLSetStatusCallback command turns off the callbackmessages so that updating the URLStatus function does not send any messages.
| |||||||||
Tags | networking |