31 namespace ip = boost::asio::ip;
39 static std::string id(
"websocket");
55 bool wantListen =
false;
62 for (
const auto& pair : *configSection) {
63 const std::string& key = pair.first;
65 if (key ==
"listen") {
68 else if (key ==
"port") {
69 port = ConfigFile::parseNumber<uint16_t>(pair,
"face_system.websocket");
71 else if (key ==
"enable_v4") {
74 else if (key ==
"enable_v6") {
78 BOOST_THROW_EXCEPTION(ConfigFile::Error(
"Unrecognized option face_system.websocket." + key));
83 if (!enableV4 && !enableV6) {
84 BOOST_THROW_EXCEPTION(ConfigFile::Error(
85 "IPv4 and IPv6 WebSocket channels have been disabled. Remove face_system.websocket section " 86 "to disable WebSocket channels or enable at least one channel type."));
94 if (!m_channels.empty()) {
95 NFD_LOG_WARN(
"Cannot disable WebSocket channels after initialization");
103 if (!v4Channel->isListening()) {
104 v4Channel->listen(this->
addFace);
111 if (!v6Channel->isListening()) {
112 v6Channel->listen(this->
addFace);
117 shared_ptr<WebSocketChannel>
120 auto it = m_channels.find(endpoint);
121 if (it != m_channels.end())
124 auto channel = make_shared<WebSocketChannel>(endpoint);
125 m_channels[endpoint] = channel;
129 std::vector<shared_ptr<const Channel>>
130 WebSocketFactory::doGetChannels()
const static bool parseYesNo(const ConfigSection &node, const std::string &key, const std::string §ionName)
parse a config option that can be either "yes" or "no"
shared_ptr< WebSocketChannel > createChannel(const websocket::Endpoint &localEndpoint)
Create WebSocket-based channel using websocket::Endpoint.
NFD_REGISTER_PROTOCOL_FACTORY(EthernetFactory)
static const std::string & getId() noexcept
boost::optional< const ConfigSection & > OptionalConfigSection
an optional config file section
Protocol factory for WebSocket.
FaceCreatedCallback addFace
callback when a new face is created
Copyright (c) 2011-2015 Regents of the University of California.
context for processing a config section in ProtocolFactory
static std::vector< shared_ptr< const Channel > > getChannelsFromMap(const ChannelMap &channelMap)
boost::asio::ip::tcp::endpoint Endpoint
#define NFD_LOG_INIT(name)