2 #include <ossia/detail/lockfree_queue.hpp>
3 #include <ossia/detail/mutex.hpp>
4 #include <ossia/network/base/listening.hpp>
5 #include <ossia/network/base/protocol.hpp>
6 #include <ossia/network/generic/generic_device.hpp>
7 #include <ossia/network/sockets/websocket_reply.hpp>
8 #include <ossia/network/zeroconf/zeroconf.hpp>
10 #include <ossia/detail/hash_map.hpp>
12 #include <nano_signal_slot.hpp>
23 class ReceivedMessage;
30 class websocket_server;
34 struct oscquery_client;
35 using clients = std::vector<std::unique_ptr<oscquery_client>>;
39 friend class query_answerer;
44 using connection_handler = std::weak_ptr<void>;
53 bool push_bundle(
const std::vector<const ossia::net::parameter_base*>&)
override;
54 bool push_raw_bundle(
const std::vector<ossia::net::full_parameter_data>&)
override;
55 bool echo_incoming_message(
66 int get_osc_port()
const {
return m_oscPort; }
68 int get_ws_port()
const {
return m_wsPort; }
71 void for_each_client(F&& f)
const
72 noexcept(noexcept(f(std::declval<const oscquery_client&>())))
74 ossia::lock_t lck{m_clientsMutex};
75 for(
auto& clt : m_clients)
81 Nano::Signal<void(
const std::string&)> onClientConnected;
82 Nano::Signal<void(
const std::string&)> onClientDisconnected;
84 void disable_zeroconf();
85 void set_zeroconf_servers(
86 net::zeroconf_server oscquery_server, net::zeroconf_server osc_server);
90 oscquery_client* find_client(
const connection_handler& hdl);
92 void add_node(std::string_view path,
const string_map<std::string>& parameters);
93 void remove_node(std::string_view path,
const std::string& node);
94 void rename_node(std::string_view node,
const std::string& new_name);
97 void on_OSCMessage(
const oscpack::ReceivedMessage& m, oscpack::IpEndpointName ip);
100 void on_connectionOpen(
const connection_handler& hdl);
101 void on_connectionClosed(
const connection_handler& hdl);
110 template <
typename T>
113 void update_zeroconf();
116 ossia::net::server_reply
117 on_WSrequest(
const connection_handler& hdl,
const std::string&
message);
118 ossia::net::server_reply
119 on_BinaryWSrequest(
const connection_handler& hdl,
const std::string&
message);
121 std::unique_ptr<osc::receiver> m_oscServer;
122 std::unique_ptr<ossia::net::websocket_server> m_websocketServer;
124 net::zeroconf_server m_zeroconfServerWS;
125 net::zeroconf_server m_zeroconfServerOSC;
128 net::listened_parameters m_listening;
131 clients m_clients TS_GUARDED_BY(m_clientsMutex);
136 std::thread m_serverThread;
139 mutable mutex_t m_clientsMutex;
142 uint16_t m_oscPort{};
146 bool m_disableZeroconf{};
153 ossia::spsc_queue<std::function<void()>> m_functionQueue;
157 class OSSIA_EXPORT oscquery_device
161 uint16_t osc_port = 1234, uint16_t ws_port = 5678, std::string name =
"oscquery");
165 ossia::net::generic_device device;
Root of a device tree.
Definition: ossia/network/base/device.hpp:58
The node_base class.
Definition: network/base/node.hpp:48
The parameter_base class.
Definition: ossia/network/base/parameter.hpp:48
The protocol_base class.
Definition: protocol.hpp:40
OSCQuery get query-answering logic.
Definition: get_query_parser.hpp:26
Implementation of an oscquery server.
Definition: oscquery_server.hpp:38
The value class.
Definition: value.hpp:173
The message struct.
Definition: message.hpp:29
Full information about a parameter.
Definition: parameter_data.hpp:61
OSCQuery JSON query-answering logic.
Definition: json_query_parser.hpp:16