This sample demonstrates the download support available in Cohernet UI. It allows the user to click on files on the web and downloads them in the working folder of the application. It also shows how a client can inbitiate a download request on any URL without having to navigate to it (press F1).
The sample solution is already configured and you only have to compile and run it.
It uses a sample mini game framework that provides very basic functionality.
The output will be in the Coherent/Samples/UI/bin directory.
Coherent::UI::EventListener::OnDownloadStarted
method is called and the Coherent::UI::Download
item is saved to monitor it's progressCoherent::UI::EventListener::OnDownloadComplete
method is called and the downloaded bytes are saved to disk.Downloads are disabled by default in Coherent UI. The user must override the Coherent::UI::EventListener::OnDownloadStarted
method and return true if she wants a particular file to be downloaded. All relevant information such as URL, referrer, size etc. can be inspected in that method.
In this sample we allow for any file to be downloaded. We also save the download object as we can use it to monitor progress or cancel the task.
Every frame the title bar of the application is updated with the name of the file currently in download and the progress it made.
When the donwload is complete the Coherent::UI::EventListener::OnDownloadComplete
method is called and the file is saved to disk.
Download requests can also be initiated by the client without the need to navigate to a particular file. This is done with the Coherent::View::DownloadUrl
method. In the sample pressing F1 causes such a download task to begin.