28 template <
typename OscqueryProtocol>
29 static json_writer::string_t handle_listen(
30 OscqueryProtocol& proto,
const oscquery_server_protocol::connection_handler& hdl,
34 auto clt = proto.find_client(hdl);
39 if(listen_text == detail::text_true())
41 clt->start_listen(std::string(path), node.get_parameter());
44 else if(listen_text == detail::text_false())
46 clt->stop_listen(std::string(path));
62 template <
typename OscqueryProtocol>
64 OscqueryProtocol& proto,
const oscquery_server_protocol::connection_handler& hdl)
66 return [&proto, &hdl](
67 std::string_view path,
68 string_map<std::string>&& parameters) -> ossia::net::server_reply {
70 if(parameters.size() == 0)
72 auto& root = proto.get_device().get_root_node();
75 return oscquery::json_writer::query_namespace(root);
79 auto node = ossia::net::find_node(root, path);
81 return oscquery::json_writer::query_namespace(*node);
88 auto host_it = parameters.find(
"HOST_INFO");
89 if(host_it == parameters.end())
91 auto node = ossia::net::find_node(proto.get_device().get_root_node(), path);
97 auto listen_it = parameters.find(detail::listen());
98 if(listen_it != parameters.end())
100 return handle_listen(proto, hdl, *node, path, listen_it->second);
104 auto html_it = parameters.find(
"HTML");
105 if(html_it != parameters.end())
107 return static_html_builder{}.build_tree(*node);
111 auto add_instance_it = parameters.find(detail::add_node());
112 if(add_instance_it != parameters.end())
114 proto.add_node(path, std::move(parameters));
119 auto rm_instance_it = parameters.find(detail::remove_node());
120 if(rm_instance_it != parameters.end())
123 proto.remove_node(path, rm_instance_it->second);
128 auto rn_instance_it = parameters.find(detail::rename_node());
129 if(rn_instance_it != parameters.end())
132 proto.rename_node(path, rn_instance_it->second);
137 ossia::small_vector<std::string, 5> attributes;
138 for(
const auto& elt : parameters)
140 if(elt.second.empty())
142 attributes.push_back(elt.first);
146 if(!attributes.empty())
148 return oscquery::json_writer::query_attributes(*node, attributes);
153 websocketpp::connection<websocketpp::config::asio>& sockets
154 = *proto.m_websocketServer->impl().get_con_from_hdl(hdl);
155 auto& socket = sockets.get_socket();
157 std::string local_client_ip = socket.local_endpoint().address().to_string();
159 auto transports = [&]() -> std::vector<ossia::net::osc_server_configuration> {
160 if constexpr(
requires { proto.get_osc_port(); })
162 ossia::net::udp_server_configuration conf;
164 conf.port = proto.get_osc_port();
169 return proto.get_transports();
173 return oscquery::json_writer::query_host_info(
174 proto.get_device().get_name(), transports(), local_client_ip,
175 proto.get_ws_port());