3#include <ossia/detail/json_fwd.hpp>
4#include <ossia/detail/lockfree_queue.hpp>
5#include <ossia/network/base/listening.hpp>
6#include <ossia/network/base/protocol.hpp>
7#include <ossia/network/oscquery/host_info.hpp>
29class websocket_client;
33struct osc_outbound_visitor;
34struct http_client_context;
40 oscquery_mirror_protocol(std::string host, uint16_t local_osc_port = 10203);
41 ~oscquery_mirror_protocol()
override;
43 bool pull(net::parameter_base&)
override;
44 std::future<void> pull_async(net::parameter_base&)
override;
45 void request(net::parameter_base&)
override;
46 bool push(
const net::parameter_base&,
const ossia::value& v)
override;
48 bool push_bundle(
const std::vector<const ossia::net::parameter_base*>&)
override;
49 bool push_raw_bundle(
const std::vector<ossia::net::full_parameter_data>&)
override;
50 bool observe(net::parameter_base&,
bool)
override;
51 bool observe_quietly(net::parameter_base&,
bool)
override;
52 bool update(net::node_base& b)
override;
53 bool echo_incoming_message(
54 const ossia::net::message_origin_identifier&
id,
57 std::future<void> update_async(net::node_base& b)
override;
60 void set_device(net::device_base& dev)
override;
86 void set_command_callback(std::function<
void()>);
99 void request_remove_node(net::node_base&);
105 void request_rename_node(net::node_base& node,
const std::string& new_name);
112 void set_zombie_on_remove(
bool zombie_on_remove)
114 m_zombie_on_remove = zombie_on_remove;
121 bool get_zombie_on_remove() const noexcept {
return m_zombie_on_remove; }
123 host_info get_host_info() const noexcept;
125 bool connected() const noexcept
override {
return m_hasWS; }
126 void connect()
override;
129 friend struct http_answer;
132 using connection_handler = std::weak_ptr<void>;
133 bool on_WSMessage(connection_handler hdl,
const std::string& message);
134 bool on_BinaryWSMessage(connection_handler hdl,
const std::string& message);
136 on_OSCMessage(
const oscpack::ReceivedMessage& m,
const oscpack::IpEndpointName& ip);
138 void cleanup_connections();
140 void http_send_message(
const std::string& str);
141 void http_send_message(
const rapidjson::StringBuffer& str);
143 void ws_send_message(
const std::string& str);
144 void ws_send_binary_message(
const std::string& str);
145 void ws_send_message(
const rapidjson::StringBuffer& str);
146 bool query_connected();
153 void on_ws_disconnected() { m_hasWS =
false; }
155 std::unique_ptr<osc::sender<oscquery::osc_outbound_visitor>> m_oscSender;
156 std::unique_ptr<osc::receiver> m_oscServer;
157 std::unique_ptr<ossia::net::websocket_client> m_websocketClient;
158 std::atomic_bool m_hasWS{};
161 net::listened_parameters m_listening;
165 std::promise<void> m_namespacePromise;
167 struct get_osc_promise
169 std::promise<void> promise;
172 struct get_ws_promise
174 get_ws_promise() =
default;
175 get_ws_promise(
const get_ws_promise&) =
delete;
176 get_ws_promise(get_ws_promise&&) noexcept = default;
177 get_ws_promise& operator=(const get_ws_promise&) = delete;
178 get_ws_promise& operator=(get_ws_promise&&) noexcept = default;
180 get_ws_promise(std::promise<
void>&& p, const std::
string& addr)
181 : promise{std::move(p)}
185 std::promise<void> promise;
186 std::string address{};
189 ossia::spsc_queue<get_ws_promise> m_getWSPromises;
190 ossia::spsc_queue<std::function<void()>> m_functionQueue;
191 std::function<void()> m_commandCallback;
193 std::thread m_wsThread;
194 std::string m_queryHost;
195 std::string m_queryPort;
196 std::string m_httpHost;
199 std::unique_ptr<http_client_context> m_http;
200 host_info m_host_info;
201 mutable std::mutex m_host_info_mutex;
203 ossia::net::message_origin_identifier m_id;
205 void set_feedback(
bool fb)
override;
206 std::atomic<bool> m_feedback{
true};
207 bool m_zombie_on_remove{
true};
Root of a device tree.
Definition ossia/network/base/device.hpp:58
The node_base class.
Definition node.hpp:48
The parameter_base class.
Definition ossia/network/base/parameter.hpp:48
The protocol_base class.
Definition protocol.hpp:40
The value class.
Definition value.hpp:173
Full information about a parameter.
Definition parameter_data.hpp:61
The data that can be found inside a parameter.
Definition parameter_data.hpp:21