NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
websocket-factory.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_DAEMON_FACE_WEBSOCKET_FACTORY_HPP
27 #define NFD_DAEMON_FACE_WEBSOCKET_FACTORY_HPP
28 
29 #include "protocol-factory.hpp"
30 #include "websocket-channel.hpp"
31 
32 namespace nfd {
33 
35 {
36 public:
41  {
42  public:
43  explicit
44  Error(const std::string& what)
45  : ProtocolFactory::Error(what)
46  {
47  }
48  };
49 
50  explicit
51  WebSocketFactory(const std::string& defaultPort);
52 
67  shared_ptr<WebSocketChannel>
68  createChannel(const websocket::Endpoint& localEndpoint);
69 
78  shared_ptr<WebSocketChannel>
79  createChannel(const std::string& localIp, const std::string& port);
80 
81  // from ProtocolFactory
82  virtual void
83  createFace(const FaceUri& uri,
84  ndn::nfd::FacePersistency persistency,
85  const FaceCreatedCallback& onCreated,
86  const FaceConnectFailedCallback& onConnectFailed) DECL_OVERRIDE;
87 
88  virtual std::list<shared_ptr<const Channel> >
89  getChannels() const;
90 
91 private:
100  shared_ptr<WebSocketChannel>
101  findChannel(const websocket::Endpoint& localEndpoint);
102 
103  typedef std::map< websocket::Endpoint, shared_ptr<WebSocketChannel> > ChannelMap;
104  ChannelMap m_channels;
105 
106  std::string m_defaultPort;
107 };
108 
109 } // namespace nfd
110 
111 #endif // NFD_DAEMON_FACE_WEBSOCKET_FACTORY_HPP
function< void(const std::string &reason)> FaceConnectFailedCallback
Prototype for the callback that is called when face is failed to get created.
represents the underlying protocol and address used by a Face
Definition: face-uri.hpp:44
shared_ptr< WebSocketChannel > createChannel(const websocket::Endpoint &localEndpoint)
Create WebSocket-based channel using websocket::Endpoint.
Exception of WebSocketFactory.
#define DECL_OVERRIDE
expands to &#39;override&#39; if compiler supports this feature, otherwise expands to nothing ...
Definition: common.hpp:49
Error(const std::string &what)
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:38
virtual std::list< shared_ptr< const Channel > > getChannels() const
Base class for all exceptions thrown by channel factories.
virtual void createFace(const FaceUri &uri, ndn::nfd::FacePersistency persistency, const FaceCreatedCallback &onCreated, const FaceConnectFailedCallback &onConnectFailed) 1
Try to create Face using the supplied FaceUri.
WebSocketFactory(const std::string &defaultPort)
function< void(const shared_ptr< Face > &newFace)> FaceCreatedCallback
Prototype for the callback called when face is created (as a response to incoming connection or after...
boost::asio::ip::tcp::endpoint Endpoint