util: use Signal in DummyClientFace

refs #2319

Change-Id: I99f3bfd4c0cd0179456070706b25e680d5a0827c
diff --git a/src/util/dummy-client-face.cpp b/src/util/dummy-client-face.cpp
index ff24326..2031a01 100644
--- a/src/util/dummy-client-face.cpp
+++ b/src/util/dummy-client-face.cpp
@@ -57,14 +57,7 @@
   virtual void
   send(const Block& wire)
   {
-    if (wire.type() == tlv::Interest) {
-      shared_ptr<Interest> interest = make_shared<Interest>(wire);
-      (*m_onInterest)(*interest);
-    }
-    else if (wire.type() == tlv::Data) {
-      shared_ptr<Data> data = make_shared<Data>(wire);
-      (*m_onData)(*data);
-    }
+    onSendBlock(wire);
   }
 
   virtual void
@@ -79,10 +72,8 @@
     return *m_ioService;
   }
 
-private:
-  friend class DummyClientFace;
-  EventEmitter<Interest>* m_onInterest;
-  EventEmitter<Data>* m_onData;
+public:
+  Signal<Transport, Block> onSendBlock;
 };
 
 DummyClientFace::DummyClientFace(const Options& options, shared_ptr<Transport> transport)
@@ -103,8 +94,19 @@
 void
 DummyClientFace::construct(const Options& options)
 {
-  m_transport->m_onInterest = &onInterest;
-  m_transport->m_onData     = &onData;
+  m_transport->onSendBlock.connect([this] (const Block& wire) {
+    if (wire.type() == tlv::Interest) {
+      shared_ptr<Interest> interest = make_shared<Interest>(wire);
+      onSendInterest(*interest);
+    }
+    else if (wire.type() == tlv::Data) {
+      shared_ptr<Data> data = make_shared<Data>(wire);
+      onSendData(*data);
+    }
+  });
+
+  onSendInterest.connect([this] (const Interest& interest) { onInterest(interest); });
+  onSendData.connect([this] (const Data& data) { onData(data); });
 
   if (options.enablePacketLogging)
     this->enablePacketLogging();
@@ -116,14 +118,18 @@
 void
 DummyClientFace::enablePacketLogging()
 {
-  onInterest += [this] (const Interest& interest) { this->sentInterests.push_back(interest); };
-  onData     += [this] (const Data& data)         { this->sentDatas.push_back(data); };
+  onSendInterest.connect([this] (const Interest& interest) {
+    this->sentInterests.push_back(interest);
+  });
+  onSendData.connect([this] (const Data& data) {
+    this->sentDatas.push_back(data);
+  });
 }
 
 void
 DummyClientFace::enableRegistrationReply()
 {
-  onInterest += [this] (const Interest& interest) {
+  onSendInterest.connect([this] (const Interest& interest) {
     static const Name localhostRegistration("/localhost/nfd/rib");
     if (!localhostRegistration.isPrefixOf(interest.getName()))
       return;
@@ -146,7 +152,7 @@
     keyChain.signWithSha256(*data);
 
     this->getIoService().post([this, data] { this->receive(*data); });
-  };
+  });
 }
 
 template<typename Packet>
diff --git a/src/util/dummy-client-face.hpp b/src/util/dummy-client-face.hpp
index 5ea9fab..8b4b8a0 100644
--- a/src/util/dummy-client-face.hpp
+++ b/src/util/dummy-client-face.hpp
@@ -23,7 +23,8 @@
 #define NDN_UTIL_DUMMY_CLIENT_FACE_HPP
 
 #include "../face.hpp"
-#include "event-emitter.hpp"
+#include "signal.hpp"
+#include "event-emitter.hpp" // deprecated
 
 namespace ndn {
 namespace util {
@@ -104,15 +105,24 @@
    */
   std::vector<Data> sentDatas;
 
-  /** \brief Event to be called whenever an Interest is received
+  /** \brief emits whenever an Interest is sent
    *
-   *  After .expressInterest, .processEvents must be called before this event would be triggered.
+   *  After .expressInterest, .processEvents must be called before this signal would be emitted.
+   */
+  Signal<DummyClientFace, Interest> onSendInterest;
+
+  /** \brief emits whenever a Data packet is sent
+   *
+   *  After .put, .processEvents must be called before this signal would be emitted.
+   */
+  Signal<DummyClientFace, Data> onSendData;
+
+public: // deprecated
+  /** \deprecated use onSendInterest
    */
   util::EventEmitter<Interest> onInterest;
 
-  /** \brief Event to be called whenever a Data packet is received
-   *
-   *  After .put, .processEvents must be called before this event would be triggered.
+  /** \deprecated use onSendData
    */
   util::EventEmitter<Data> onData;