37 : m_localEndpoint(localEndpoint)
38 , m_pingInterval(
time::seconds(10))
66 m_pingInterval = interval;
80 auto it = m_channelFaces.find(hdl);
81 if (it != m_channelFaces.end()) {
92 auto it = m_channelFaces.find(hdl);
93 if (it != m_channelFaces.end()) {
105 auto it = m_channelFaces.find(hdl);
106 if (it != m_channelFaces.end()) {
107 static_cast<WebSocketTransport*
>(it->second->getTransport())->receiveMessage(msg->get_payload());
119 auto linkService = make_unique<GenericLinkService>();
120 auto transport = make_unique<WebSocketTransport>(hdl, ref(m_server), m_pingInterval);
121 auto face = make_shared<Face>(std::move(linkService), std::move(transport));
123 BOOST_ASSERT(m_channelFaces.count(hdl) == 0);
124 m_channelFaces[hdl] = face;
127 m_onFaceCreatedCallback(face);
133 auto it = m_channelFaces.find(hdl);
134 if (it != m_channelFaces.end()) {
150 m_onFaceCreatedCallback = onFaceCreated;
152 m_server.
listen(m_localEndpoint);
static level const all
Special aggregate value representing "all levels".
void listen(const FaceCreatedCallback &onFaceCreated)
Enable listening on the local endpoint, accept connections, and create faces when remote host makes a...
void set_pong_timeout_handler(pong_timeout_handler h)
void setUri(const FaceUri &uri)
void set_open_handler(open_handler h)
void set_reuse_addr(bool value)
Sets whether to use the SO_REUSEADDR flag when opening listening sockets.
boost::posix_time::time_duration milliseconds(long duration)
connection_type::message_ptr message_ptr
Type of message pointers that this endpoint uses.
lib::weak_ptr< void > connection_hdl
A handle to uniquely identify a connection.
detail::SimulatorIo & getGlobalIoService()
connection_ptr get_con_from_hdl(connection_hdl hdl, lib::error_code &ec)
Retrieves a connection_ptr from a connection_hdl (exception free)
void connectFaceClosedSignal(Face &face, const std::function< void()> &f)
invokes a callback when the face is closed
void set_close_handler(close_handler h)
void init_asio(io_service_ptr ptr, lib::error_code &ec)
initialize asio transport with external io_service (exception free)
#define NFD_LOG_CHAN_DEBUG(msg)
Log a message at DEBUG level.
WebSocketChannel(const websocket::Endpoint &localEndpoint)
Create WebSocket channel for the local endpoint.
Copyright (c) 2011-2015 Regents of the University of California.
bool is_listening() const
Check if the endpoint is listening.
#define NFD_LOG_CHAN_INFO(msg)
Log a message at INFO level.
#define NFD_LOG_CHAN_TRACE(msg)
Log a message at TRACE level.
#define NFD_LOG_CHAN_WARN(msg)
Log a message at WARN level.
void start_accept(lib::error_code &ec)
Starts the server's async connection acceptance loop (exception free)
void set_pong_handler(pong_handler h)
void clear_error_channels(log::level channels)
Clear Error logging channels.
represents the underlying protocol and address used by a Face
bool isListening() const override
Returns whether the channel is listening.
void clear_access_channels(log::level channels)
Clear Access logging channels.
A Transport that communicates on a WebSocket connection.
void set_pong_timeout(long dur)
Set pong timeout.
boost::asio::ip::tcp::endpoint Endpoint
void listen(lib::asio::ip::tcp::endpoint const &ep, lib::error_code &ec)
Set up endpoint for listening manually (exception free)
#define NFD_LOG_INIT(name)
void set_message_handler(message_handler h)
static level const all
Special aggregate value representing "all levels".
function< void(const shared_ptr< Face > &newFace)> FaceCreatedCallback
Prototype for the callback that is invoked when a face is created (in response to an incoming connect...