37 if (addr.is_loopback()) {
42 else if (addr.is_v6()) {
43 auto addr6 = addr.to_v6();
44 if (addr6.is_v4_mapped()) {
45 return addr6.to_v4().is_loopback();
57 , m_pingInterval(pingInterval)
63 if (
isLoopback(sock.local_endpoint().address()) &&
64 isLoopback(sock.remote_endpoint().address())) {
81 WebSocketTransport::doSend(
const Block& packet)
85 websocketpp::lib::error_code error;
89 return processErrorCode(error);
101 std::tie(isOk, element) =
Block::fromBuffer({
reinterpret_cast<const uint8_t*
>(msg.data()), msg.size()});
111 WebSocketTransport::schedulePing()
113 m_pingEventId =
getScheduler().schedule(m_pingInterval, [
this] { sendPing(); });
117 WebSocketTransport::sendPing()
121 websocketpp::lib::error_code error;
122 m_server.
ping(m_handle,
"NFD-WebSocket", error);
124 return processErrorCode(error);
128 this->schedulePing();
148 WebSocketTransport::processErrorCode(
const websocketpp::lib::error_code& error)
171 websocketpp::lib::error_code error;
void setPersistency(ndn::nfd::FacePersistency newPersistency)
changes face persistency setting
static NDN_CXX_NODISCARD std::tuple< bool, Block > fromBuffer(ConstBufferPtr buffer, size_t offset=0)
Try to parse Block from a wire buffer.
#define NFD_LOG_INIT(name)
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)
#define NFD_LOG_FACE_ERROR(msg)
Log a message at ERROR level.
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 the 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)
const uint8_t * wire() const
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)
Scheduler & getScheduler()
Returns the global Scheduler instance for the calling thread.
#define NFD_LOG_FACE_DEBUG(msg)
Log a message at DEBUG level.
void receive(const Block &packet, const EndpointId &endpoint=0)
Pass a received link-layer packet to the upper layer for further processing.
size_t size() const
Return the size of the encoded wire, i.e., of the whole TLV.
static bool isLoopback(const boost::asio::ip::address &addr)
TransportState getState() const
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
void cancel()
Cancel the operation.
A Transport that communicates on a WebSocket connection.
void close(connection_hdl hdl, close::status::value const code, std::string const &reason, lib::error_code &ec)
void setState(TransportState newState)
set transport state
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.
boost::chrono::milliseconds milliseconds