test: basic unit-test for WebSocket face
Change-Id: I41dcc2ecff57225db1aff8e359d507f0e89d4c96
Refs: #1553
diff --git a/daemon/face/websocket-channel.cpp b/daemon/face/websocket-channel.cpp
index 5cf98f6..234faff 100644
--- a/daemon/face/websocket-channel.cpp
+++ b/daemon/face/websocket-channel.cpp
@@ -44,6 +44,8 @@
m_server.set_open_handler(bind(&WebSocketChannel::handleOpen, this, _1));
m_server.set_close_handler(bind(&WebSocketChannel::handleClose, this, _1));
m_server.init_asio(&getGlobalIoService());
+ // Always set SO_REUSEADDR flag
+ m_server.set_reuse_addr(true);
this->setUri(FaceUri(localEndpoint, "ws"));
}
diff --git a/daemon/face/websocket-channel.hpp b/daemon/face/websocket-channel.hpp
index 05d8f99..62c4940 100644
--- a/daemon/face/websocket-channel.hpp
+++ b/daemon/face/websocket-channel.hpp
@@ -85,6 +85,9 @@
size_t
size() const;
+ bool
+ isListening() const;
+
private:
void
handleMessage(websocketpp::connection_hdl hdl, websocket::Server::message_ptr msg);
@@ -117,6 +120,12 @@
};
+inline bool
+WebSocketChannel::isListening() const
+{
+ return m_isListening;
+}
+
} // namespace nfd
#endif // NFD_DAEMON_FACE_WEBSOCKET_CHANNEL_HPP