NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
websocket-transport.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_TRANSPORT_HPP
27 #define NFD_DAEMON_FACE_WEBSOCKET_TRANSPORT_HPP
28 
29 #include "transport.hpp"
30 #include "websocketpp.hpp"
31 #include "core/scheduler.hpp"
32 
33 namespace nfd {
34 namespace face {
35 
41 {
42 public:
46 
50 };
51 
54 class WebSocketTransport final : public Transport
55  , protected virtual WebSocketTransportCounters
56 {
57 public:
61 
62  WebSocketTransport(websocketpp::connection_hdl hdl,
63  websocket::Server& server,
64  time::milliseconds pingInterval);
65 
66  const Counters&
67  getCounters() const final;
68 
72  void
73  receiveMessage(const std::string& msg);
74 
75  void
76  handlePong();
77 
78  void
80 
81 protected:
82  void
83  doClose() final;
84 
85 private:
86  void
87  doSend(Transport::Packet&& packet) final;
88 
89  void
90  schedulePing();
91 
92  void
93  sendPing();
94 
95  void
96  processErrorCode(const websocketpp::lib::error_code& error);
97 
98 private:
99  websocketpp::connection_hdl m_handle;
100  websocket::Server& m_server;
101  time::milliseconds m_pingInterval;
102  scheduler::ScopedEventId m_pingEventId;
103 };
104 
105 inline const WebSocketTransport::Counters&
107 {
108  return *this;
109 }
110 
111 } // namespace face
112 } // namespace nfd
113 
114 #endif // NFD_DAEMON_FACE_WEBSOCKET_TRANSPORT_HPP
counters provided by WebSocketTransport
websocketpp::server< websocketpp::config::asio > Server
Definition: websocketpp.hpp:46
stores a packet along with the remote endpoint
Definition: transport.hpp:122
counters provided by Transport
Definition: transport.hpp:58
WebSocketTransport(websocketpp::connection_hdl hdl, websocket::Server &server, time::milliseconds pingInterval)
represents a counter of number of packets
Definition: counter.hpp:77
void receiveMessage(const std::string &msg)
Translates a message into a Block and delivers it to the link service.
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
const Counters & getCounters() const final
WebSocketTransportCounters Counters
counters provided by WebSocketTransport
PacketCounter nOutPings
count of outgoing Pings
PacketCounter nInPongs
count of incoming Pongs
A Transport that communicates on a WebSocket connection.
the lower part of a Face
Definition: transport.hpp:113
void doClose() final
performs Transport specific operations to close the transport