Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NETWORKING: Enter Session and SessionRequest #1914

Merged
merged 4 commits into from Nov 5, 2019

Conversation

@Tkachov
Copy link
Contributor

Tkachov commented Nov 3, 2019

Originally intended to be a speedup for libcurl by reusing the same handle in keep-alive connections. Turns out, libcurl automatically does that.

Anyways, this PR does some useful edits in backends/networking/curl and adds SessionRequest, which might be not only used asynchronously as before (via callbacks), but also synchronously using wait(). Session class allows to reuse these SessionRequests.

Tkachov added 4 commits Nov 1, 2019
It is to be used in a Session, though it might be used separately. It
must implement keep-alive, but it does not yet.

You must not put it to ConnMan by yourself (instead, use start()) and
you must call close() after you've finished using this request.

You can either work with it in callback, or wait() and simply use its
methods (check it's success() and then, for example, use text()). Like
this:
```
Networking::SessionRequest *rq = new Networking::SessionRequest(url);
rq->startAndWait();
if (rq->success())
warning("HTTP GET: %s", rq->text());
rq->close();
```
Session allows to reuse SessionRequests to the same host by making them
keeping alive connection. Turns out, though, that libcurl already does
that for us, and we didn't gain any speedup we thought we'd get.

Usage:
```
Networking::Session s;
Networking::SessionRequest *request = s.get(url);
request->startAndWait();
warning("HTTP GET: %s", request->text());
s.close();
```

You can still use SessionRequest without Session (but you can't put them
on stack!):
```
Networking::SessionRequest *request = new
Networking::SessionRequest(url);
request->startAndWait();
warning("HTTP GET: %s", request->text());
request->close();
```
@Tkachov Tkachov force-pushed the Tkachov:keep-alive branch from e3b83fb to e8b4645 Nov 4, 2019
@sev-

This comment has been minimized.

Copy link
Member

sev- commented Nov 5, 2019

Thanks! Merging

@sev- sev- merged commit 99e21f4 into scummvm:master Nov 5, 2019
1 of 2 checks passed
1 of 2 checks passed
Codacy/PR Quality Review Not up to standards. This pull request quality could be better.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.