face: connect to Transport during construction
This allows DummyClientFace to receive packets without sending.
refs #2318
Change-Id: I7451d2c4a873e4680cfb380c9029b1edcd4af7fb
diff --git a/src/detail/face-impl.hpp b/src/detail/face-impl.hpp
index 248aca3..460d316 100644
--- a/src/detail/face-impl.hpp
+++ b/src/detail/face-impl.hpp
@@ -101,15 +101,21 @@
/////////////////////////////////////////////////////////////////////////////////////////////////
void
- asyncExpressInterest(const shared_ptr<const Interest>& interest,
- const OnData& onData, const OnTimeout& onTimeout)
+ ensureConnected(bool wantResume = true)
{
if (!m_face.m_transport->isConnected())
m_face.m_transport->connect(m_face.m_ioService,
bind(&Face::onReceiveElement, &m_face, _1));
- if (!m_face.m_transport->isExpectingData())
+ if (wantResume && !m_face.m_transport->isExpectingData())
m_face.m_transport->resume();
+ }
+
+ void
+ asyncExpressInterest(const shared_ptr<const Interest>& interest,
+ const OnData& onData, const OnTimeout& onTimeout)
+ {
+ this->ensureConnected();
m_pendingInterestTable.push_back(make_shared<PendingInterest>(interest, onData, onTimeout));
@@ -141,12 +147,7 @@
void
asyncPutData(const shared_ptr<const Data>& data)
{
- if (!m_face.m_transport->isConnected())
- m_face.m_transport->connect(m_face.m_ioService,
- bind(&Face::onReceiveElement, &m_face, _1));
-
- if (!m_face.m_transport->isExpectingData())
- m_face.m_transport->resume();
+ this->ensureConnected();
if (!data->getLocalControlHeader().empty(false, true))
{