NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
websocket-factory.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26
#include "
websocket-factory.hpp
"
27
28
namespace
nfd
{
29
30
namespace
ip
=
boost::asio::ip
;
31
32
shared_ptr<WebSocketChannel>
33
WebSocketFactory::createChannel
(
const
websocket::Endpoint
& endpoint)
34
{
35
auto
channel = findChannel(endpoint);
36
if
(channel)
37
return
channel;
38
39
channel = make_shared<WebSocketChannel>(endpoint);
40
m_channels[endpoint] = channel;
41
42
return
channel;
43
}
44
45
shared_ptr<WebSocketChannel>
46
WebSocketFactory::createChannel
(
const
std::string& localIp,
const
std::string& localPort)
47
{
48
websocket::Endpoint
endpoint(ip::address::from_string(localIp),
49
boost::lexical_cast<uint16_t>(localPort));
50
return
createChannel
(endpoint);
51
}
52
53
void
54
WebSocketFactory::createFace
(
const
FaceUri
& uri,
55
ndn::nfd::FacePersistency
persistency,
56
const
FaceCreatedCallback
& onCreated,
57
const
FaceCreationFailedCallback
& onConnectFailed)
58
{
59
BOOST_THROW_EXCEPTION(
Error
(
"WebSocketFactory does not support 'createFace' operation"
));
60
}
61
62
std::vector<shared_ptr<const Channel>>
63
WebSocketFactory::getChannels
()
const
64
{
65
std::vector<shared_ptr<const Channel>> channels;
66
channels.reserve(m_channels.size());
67
68
for
(
const
auto
& i : m_channels)
69
channels.push_back(i.second);
70
71
return
channels;
72
}
73
74
shared_ptr<WebSocketChannel>
75
WebSocketFactory::findChannel(
const
websocket::Endpoint
& endpoint)
const
76
{
77
auto
i = m_channels.find(endpoint);
78
if
(i != m_channels.end())
79
return
i->second;
80
else
81
return
nullptr
;
82
}
83
84
}
// namespace nfd
nfd::WebSocketFactory::createFace
virtual void createFace(const FaceUri &uri, ndn::nfd::FacePersistency persistency, const FaceCreatedCallback &onCreated, const FaceCreationFailedCallback &onConnectFailed) 1
Try to create Face using the supplied FaceUri.
Definition:
websocket-factory.cpp:54
nfd::FaceCreationFailedCallback
function< void(const std::string &reason)> FaceCreationFailedCallback
Prototype for the callback that is invoked when the face fails to be created.
Definition:
channel.hpp:44
ndn::util::FaceUri
represents the underlying protocol and address used by a Face
Definition:
face-uri.hpp:44
nfd::WebSocketFactory::createChannel
shared_ptr< WebSocketChannel > createChannel(const websocket::Endpoint &localEndpoint)
Create WebSocket-based channel using websocket::Endpoint.
Definition:
websocket-factory.cpp:33
nfd::WebSocketFactory::Error
Exception of WebSocketFactory.
Definition:
websocket-factory.hpp:40
ndn::nfd::FacePersistency
FacePersistency
Definition:
nfd-constants.hpp:49
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:40
websocket-factory.hpp
boost::asio::ip
Definition:
tcp-transport.hpp:31
nfd::FaceCreatedCallback
function< void(const shared_ptr< Face > &newFace)> FaceCreatedCallback
Prototype for the callback that is invoked when the face is created (as a response to incoming connec...
Definition:
channel.hpp:38
nfd::WebSocketFactory::getChannels
virtual std::vector< shared_ptr< const Channel > > getChannels() const 1
Definition:
websocket-factory.cpp:63
nfd::websocket::Endpoint
boost::asio::ip::tcp::endpoint Endpoint
Definition:
websocket-channel.hpp:35
ndnSIM
NFD
daemon
face
websocket-factory.cpp
Generated on Sat Nov 12 2016 16:02:54 for ndnSIM by
1.8.12