Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

Potentially complex network application construction

$
0
0
I’m writing an application to a RESTful API where an auth token might time out and therefore a request might fail and a re-auth might be needed. It could fail for other reasons as well, of course. It’s not too hard to set it up if you assume every request will succeed. But I’m wondering if I can get some best-practice pointers on how to set this kind of thing up in a real world scenario. I don’t have extensive Qt experience but understand it reasonably well. I’m planning to have a single method to construct and send requests, because many of the request types have similarities. There may also be multiple requests in progress at the same time. I am now thinking of maintaining a QVector<QNetworkRequest> and put the request in as it is constructed. A slot to read the reply (connected to finished() on QNetworkReply) could check the origination of the request, fetch the original request with request(), reference that to see what it was looking for, and parse accordingly. If it needs re-authentication it could do that, then try the request again. I guess I could use custom attributes of QNetworkRequest to say what type of request it was. Once it was all successful it could remove the request from the QVector. Seems like a bit of a mess. Is there an elegant way to set this up? Thanks!

Viewing all articles
Browse latest Browse all 18427

Trending Articles