Aborting transfers
Users should always be able to terminate file transfers if at all possible, even if you don't expect that the transfer will take very long. You don't know their network conditions, and as such, it's possible that even a short file might take far longer than anyone would expect (especially if network conditions are very poor). That said, you don't have to offer an option immediately; you might want to wait a few seconds to give the transfer time to complete before offering the user a method for aborting the operation just to ensure they don't accidentally press whatever button they see appearing on their screen.
Aborting a transfer is easy: there's an abort
method on any instance of FileTransfer
that will stop the operation and call the error handler. The error code will always be FileTransferError.ABORT_ERR
, so your error handler can properly notify the rest of your app about the termination.
Note
The snippets in this section are located at snippets/09/ex4-abort
in the code...