face: TcpTransport
Change-Id: I3ff898225ad1b0c1178490f389048944e24a9f1b
Refs: #3166
diff --git a/daemon/face/tcp-channel.cpp b/daemon/face/tcp-channel.cpp
index b46e92c..2549c66 100644
--- a/daemon/face/tcp-channel.cpp
+++ b/daemon/face/tcp-channel.cpp
@@ -24,14 +24,15 @@
*/
#include "tcp-channel.hpp"
-#include "tcp-face.hpp"
+#include "generic-link-service.hpp"
+#include "tcp-transport.hpp"
#include "core/global-io.hpp"
namespace nfd {
NFD_LOG_INIT("TcpChannel");
-using namespace boost::asio;
+namespace ip = boost::asio::ip;
TcpChannel::TcpChannel(const tcp::Endpoint& localEndpoint)
: m_localEndpoint(localEndpoint)
@@ -94,24 +95,21 @@
}
void
-TcpChannel::createFace(ip::tcp::socket socket,
+TcpChannel::createFace(ip::tcp::socket&& socket,
const FaceCreatedCallback& onFaceCreated,
bool isOnDemand)
{
- shared_ptr<Face> face;
+ shared_ptr<face::LpFaceWrapper> face;
tcp::Endpoint remoteEndpoint = socket.remote_endpoint();
auto it = m_channelFaces.find(remoteEndpoint);
if (it == m_channelFaces.end()) {
- tcp::Endpoint localEndpoint = socket.local_endpoint();
-
- if (localEndpoint.address().is_loopback() &&
- remoteEndpoint.address().is_loopback())
- face = make_shared<TcpLocalFace>(FaceUri(remoteEndpoint), FaceUri(localEndpoint),
- std::move(socket), isOnDemand);
- else
- face = make_shared<TcpFace>(FaceUri(remoteEndpoint), FaceUri(localEndpoint),
- std::move(socket), isOnDemand);
+ auto persistency = isOnDemand ? ndn::nfd::FACE_PERSISTENCY_ON_DEMAND
+ : ndn::nfd::FACE_PERSISTENCY_PERSISTENT;
+ auto linkService = make_unique<face::GenericLinkService>();
+ auto transport = make_unique<face::TcpTransport>(std::move(socket), persistency);
+ auto lpFace = make_unique<face::LpFace>(std::move(linkService), std::move(transport));
+ face = make_shared<face::LpFaceWrapper>(std::move(lpFace));
face->onFail.connectSingleShot([this, remoteEndpoint] (const std::string&) {
NFD_LOG_TRACE("Erasing " << remoteEndpoint << " from channel face map");