Move the elementReader_ to a member of TcpTransport
diff --git a/tests/test-get-async.cpp b/tests/test-get-async.cpp
index fd2c1cc..b2a797a 100644
--- a/tests/test-get-async.cpp
+++ b/tests/test-get-async.cpp
@@ -17,9 +17,15 @@
class MyClosure : public Closure {
public:
+ MyClosure()
+ : gotContent_(false)
+ {
+ }
+
virtual UpcallResult upcall(UpcallKind kind, UpcallInfo &upcallInfo)
{
if (kind == UPCALL_CONTENT || kind == UPCALL_CONTENT_UNVERIFIED) {
+ gotContent_ = true;
cout << "Got content with name " << upcallInfo.getContentObject()->getName().to_uri() << endl;
for (unsigned int i = 0; i < upcallInfo.getContentObject()->getContent().size(); ++i)
cout << upcallInfo.getContentObject()->getContent()[i];
@@ -30,16 +36,21 @@
else
return CLOSURE_RESULT_OK;
}
+
+ bool gotContent_;
};
int main(int argc, char** argv)
{
try {
shared_ptr<TcpTransport> transport(new TcpTransport());
+ shared_ptr<MyClosure> closure(new MyClosure());
NDN ndn(transport, "E.hub.ndn.ucla.edu", 9695);
- ndn.expressInterest(Name("/ndn/ucla.edu/apps/ndn-js-test/hello.txt/level2/%FD%05%0B%16%7D%95%0E"), make_shared<MyClosure>(), 0);
+ ndn.expressInterest(Name("/ndn/ucla.edu/apps/ndn-js-test/hello.txt/level2/%FD%05%0B%16%7D%95%0E"), closure, 0);
- transport->tempReceive();
+ // Pump the receive process. This should really be done by a socket listener.
+ while (!closure->gotContent_)
+ transport->tempReceive();
} catch (std::exception &e) {
cout << "exception: " << e.what() << endl;
}