Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (device)
Viewing all articles
Browse latest Browse all 250

HTTPClient async property

0
0

My env is : Titanium SDK 3.2.2.GA, OS X Mavericks 10.9.2, iOS7, iOS simulator, Xcode 5.0.2

I use httpClient to download bunch of files from server, and that download process was blocking the user interface and making the application seem "hang" while the download is in progress. So I set async to true:

var httpClient = Ti.Network.createHTTPClient({
                validatesSecureCertificate : false,
                cache : false
            });
httpClient.timeout = 60 * 1000;
 
http.onreadystatechange = function() {
    if (http.readyState == 4 && http.status == 200) {
        var file = Ti.Filesystem.getFile(showFolder + Ti.Filesystem.separator + docType, fileName);
        file.write(this.responseData);
        file = null;
        http.responseXML = null;
        http.responseData = null;
        http.responseText = null;
        http = null;
    }
};
 
var downloadParams = {
    show_id : 'show_id',
    id : 'file_id',
    dirLabel : 'object_id',
    password : 'password',
    user_id : 'user_id',
    url : 'file_url',
    username : 'username',
    pdf : "1"
};
 
http.open("POST", 'https://server_name/apps/desktop/downloadFile.php', true);
http.send(downloadParams);
It seems to me that async does't work on a device. In simulator I noticed the difference, but on a device it the same behaviour, no matter if async is true or false. Is this a bug? Can someone confirm this, please.

Viewing all articles
Browse latest Browse all 250

Latest Images

Trending Articles





Latest Images