Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Developer
Posts: 4
Registered: ‎03-04-2013
My Device: Dev Alpha B
My Carrier: Telia
Accepted Solution

QNetworkAccessManager or similar for synchronous data traffic

[ Edited ]

Hi everyone,

 

I use a priority_queue (in a separate thread) for prioritizing my data requests (e.g. thumbnail images first, then larger images, unless the user wants a specific larger image, then that request is expedited) and JSON API calls.

 

If I use QNetworkAccessManager as it is and dump requests into it, it won't handle higher priority requests. I would like to do synchronous traffic. Is there a way to do this with QNetworkAccessManager, or is there some other alternative way to do this that you recommend?

 

/Alexander Yngling

Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: QNetworkAccessManager or similar for synchronous data traffic

I'd suggest not to send another request until response received (or timer expired - according to your app logic).

New Developer
Posts: 4
Registered: ‎03-04-2013
My Device: Dev Alpha B
My Carrier: Telia

Re: QNetworkAccessManager or similar for synchronous data traffic

[ Edited ]
Thank you for your comment. That is my backup plan, yes. It feels a little silly to need another mutex and condition variable just for this, though.
Highlighted
New Developer
Posts: 4
Registered: ‎03-04-2013
My Device: Dev Alpha B
My Carrier: Telia

Re: QNetworkAccessManager or similar for synchronous data traffic

In case someone else ends up here with the same question, I ended up using cURL instead. (It's included with the ndk, just #include<curl/curl.h> and put LIBS += -lcurl inyour .pro file.) Works great.

 

cf. http://curl.haxx.se/libcurl/c/example.html

 

/Alexander Yngling