NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
websocket-face.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_FACE_HPP
27 #define NFD_DAEMON_FACE_WEBSOCKET_FACE_HPP
28 
29 #include "face.hpp"
30 #include "core/scheduler.hpp"
31 
32 #ifndef HAVE_WEBSOCKET
33 #error "Cannot include this file when WebSocket support is not enabled"
34 #endif // HAVE_WEBSOCKET
35 
36 #include "websocketpp.hpp"
37 
38 namespace nfd {
39 
40 namespace websocket {
41 typedef boost::asio::ip::tcp::endpoint Endpoint;
42 typedef websocketpp::server<websocketpp::config::asio> Server;
43 } // namespace websocket
44 
45 
50 class WebSocketFace : public Face
51 {
52 public:
53  WebSocketFace(const FaceUri& remoteUri, const FaceUri& localUri,
54  websocketpp::connection_hdl hdl, websocket::Server& server);
55 
56  // from Face
57  void
58  sendInterest(const Interest& interest) DECL_OVERRIDE;
59 
60  void
61  sendData(const Data& data) DECL_OVERRIDE;
62 
63  void
64  close() DECL_OVERRIDE;
65 
66  void
68  {
69  m_pingEventId = id;
70  }
71 
72 protected:
73  // friend because it needs to invoke protected handleReceive
74  friend class WebSocketChannel;
75 
76  void
77  handleReceive(const std::string& msg);
78 
79 private:
80  websocketpp::connection_hdl m_handle;
81  websocket::Server& m_server;
82  scheduler::EventId m_pingEventId;
83  bool m_closed;
84 };
85 
86 } // namespace nfd
87 
88 #endif // NFD_DAEMON_FACE_WEBSOCKET_FACE_HPP
websocketpp::server< websocketpp::config::asio > Server
represents the underlying protocol and address used by a Face
Definition: face-uri.hpp:44
represents an Interest packet
Definition: interest.hpp:45
std::shared_ptr< ns3::EventId > EventId
Definition: scheduler.hpp:39
#define DECL_OVERRIDE
expands to &#39;override&#39; if compiler supports this feature, otherwise expands to nothing ...
Definition: common.hpp:49
represents a face
Definition: face.hpp:57
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:38
Implementation of Face abstraction that uses WebSocket as underlying transport mechanism.
Class implementing WebSocket-based channel to create faces.
void setPingEventId(scheduler::EventId &id)
boost::asio::ip::tcp::endpoint Endpoint
represents a Data packet
Definition: data.hpp:39