Class implementing WebSocket-based channel to create faces. More...
#include <websocket-channel.hpp>
Public Member Functions | |
WebSocketChannel (const websocket::Endpoint &localEndpoint) | |
Create WebSocket channel for the local endpoint. More... | |
void | listen (const FaceCreatedCallback &onFaceCreated) |
Enable listening on the local endpoint, accept connections, and create faces when remote host makes a connection. More... | |
size_t | size () const |
Get number of faces in the channel. More... | |
bool | isListening () const |
Public Member Functions inherited from nfd::Channel | |
virtual | ~Channel () |
const FaceUri & | getUri () const |
Additional Inherited Members | |
Public Types inherited from nfd::Channel | |
typedef function< void(const shared_ptr< Face > &newFace)> | FaceCreatedCallback |
Prototype for the callback called when face is created (as a response to incoming connection or after connection is established) More... | |
typedef function< void(const std::string &reason)> | ConnectFailedCallback |
Prototype for the callback that is called when face is failed to get created. More... | |
Protected Member Functions inherited from nfd::Channel | |
void | setUri (const FaceUri &uri) |
Class implementing WebSocket-based channel to create faces.
Definition at line 37 of file websocket-channel.hpp.
|
explicit |
Create WebSocket channel for the local endpoint.
To enable creation of faces upon incoming connections, one needs to explicitly call WebSocketChannel::listen method. The created socket is bound to the localEndpoint.
WebSocketChannel::Error | if bind on the socket fails |
Definition at line 36 of file websocket-channel.cpp.
References nfd::getGlobalIoService(), nfd::Channel::getUri(), NFD_LOG_TRACE, NFD_LOG_WARN, nfd::scheduler::schedule(), and nfd::Channel::setUri().
void nfd::WebSocketChannel::listen | ( | const FaceCreatedCallback & | onFaceCreated | ) |
Enable listening on the local endpoint, accept connections, and create faces when remote host makes a connection.
onFaceCreated | Callback to notify successful creation of the face |
WebSocketChannel::Error | if called multiple times |
Definition at line 168 of file websocket-channel.cpp.
References isListening(), and NFD_LOG_WARN.
size_t nfd::WebSocketChannel::size | ( | ) | const |
Get number of faces in the channel.
Definition at line 182 of file websocket-channel.cpp.
|
inline |
Definition at line 118 of file websocket-channel.hpp.
Referenced by listen().