36 if (addr.is_loopback()) {
41 else if (addr.is_v6()) {
42 auto addr6 = addr.to_v6();
43 if (addr6.is_v4_mapped()) {
44 return addr6.to_v4().is_loopback();
56 , m_pingInterval(pingInterval)
62 if (
isLoopback(sock.local_endpoint().address()) &&
63 isLoopback(sock.remote_endpoint().address())) {
84 websocketpp::lib::error_code error;
85 m_server.
send(m_handle, packet.packet.wire(), packet.packet.size(),
88 return processErrorCode(error);
100 std::tie(isOk, element) =
Block::fromBuffer(reinterpret_cast<const uint8_t*>(msg.c_str()), msg.size());
110 WebSocketTransport::schedulePing()
112 m_pingEventId =
scheduler::schedule(m_pingInterval, bind(&WebSocketTransport::sendPing,
this));
116 WebSocketTransport::sendPing()
120 websocketpp::lib::error_code error;
121 m_server.
ping(m_handle,
"NFD-WebSocket", error);
123 return processErrorCode(error);
127 this->schedulePing();
147 WebSocketTransport::processErrorCode(
const websocketpp::lib::error_code& error)
170 websocketpp::lib::error_code error;
void setPersistency(ndn::nfd::FacePersistency newPersistency)
changes face persistency setting
void cancel()
cancels the event manually
static std::tuple< bool, Block > fromBuffer(ConstBufferPtr buffer, size_t offset)
Try to parse Block from a wire buffer.
void ping(connection_hdl hdl, std::string const &payload, lib::error_code &ec)
Send a ping to a specific connection.
#define NFD_LOG_FACE_TRACE(msg)
Log a message at TRACE level.
const ssize_t MTU_UNLIMITED
indicates the transport has no limit on payload size
void setRemoteUri(const FaceUri &uri)
boost::posix_time::time_duration milliseconds(long duration)
#define NFD_LOG_FACE_ERROR(msg)
Log a message at ERROR level.
stores a packet along with the remote endpoint
static value const normal
Normal closure, meaning that the purpose for which the connection was established has been fulfilled...
lib::weak_ptr< void > connection_hdl
A handle to uniquely identify a connection.
Represents a TLV element of NDN packet format.
WebSocketTransport(websocketpp::connection_hdl hdl, websocket::Server &server, time::milliseconds pingInterval)
void setLinkType(ndn::nfd::LinkType linkType)
connection_ptr get_con_from_hdl(connection_hdl hdl, lib::error_code &ec)
Retrieves a connection_ptr from a connection_hdl (exception free)
void receiveMessage(const std::string &msg)
Translates a message into a Block and delivers it to the link service.
the transport is being closed due to a failure
void setScope(ndn::nfd::FaceScope scope)
static bool isLoopback(const boost::asio::ip::address &addr)
#define NFD_LOG_FACE_INFO(msg)
Log a message at INFO level.
Copyright (c) 2011-2015 Regents of the University of California.
the transport is closed, and can be safely deallocated
void setLocalUri(const FaceUri &uri)
PacketCounter nOutPings
count of outgoing Pings
PacketCounter nInPongs
count of incoming Pongs
the transport is being closed gracefully, either by the peer or by a call to close() ...
represents the underlying protocol and address used by a Face
EventId schedule(time::nanoseconds after, const EventCallback &event)
schedule an event
void close(connection_hdl hdl, close::status::value const code, std::string const &reason, lib::error_code &ec)
TransportState getState() const
void setState(TransportState newState)
set transport state
void receive(Packet &&packet)
receive a link-layer packet
#define NFD_LOG_INIT(name)
void send(connection_hdl hdl, std::string const &payload, frame::opcode::value op, lib::error_code &ec)
Create a message and add it to the outgoing send queue (exception free)
void doClose() final
performs Transport specific operations to close the transport
#define NFD_LOG_FACE_WARN(msg)
Log a message at WARN level.