OSSIA
Open Scenario System for Interactive Application
ossia-pd/src/client.hpp
1 #pragma once
2 #include <ossia/network/local/local.hpp>
3 #include <ossia/network/oscquery/oscquery_mirror.hpp>
4 #include <ossia/network/zeroconf/zeroconf.hpp>
5 
6 #include <ossia-pd/src/device_base.hpp>
7 
8 namespace ossia::pd
9 {
10 
11 class client : public device_base
12 {
13 public:
14  client();
15 
16  using is_client = std::true_type;
17 
18  static void register_children(client* x);
19  void unregister_children();
20 
21  static void print_protocol_help()
22  {
23  post("connect <protocol> <args> ...");
24  post("or");
25  post("connect <device_name>");
26  post("the later will look for a device with that name on the network");
27  post("Available protocols (case insensitive): minuit, oscquery");
28  post("Protocols parameters :");
29  post(
30  "minuit <remoteip> <remoteport> <localport> :\n"
31  "\tremoteip (symbol): ip of target device\n"
32  "\tremoteport (float): port on which packet should be send\n"
33  "\tlocalport (float): port to which this device is listening");
34  post(
35  "oscquery <oscport> <wsurl> :\n"
36  "\twsurl (symbol) : url to connect to (default : "
37  "ws://127.0.0.1:5678)\n");
38  post(
39  "osc <oscport> :\n"
40  "\tip (string) : ip to connect to"
41  "\toscport (float) : port to connect to");
42  }
43 
44  std::vector<ossia::net::minuit_connection_data> m_minuit_devices{};
45  std::vector<ossia::net::oscquery_connection_data> m_oscq_devices{};
46 
47  ossia::oscquery::oscquery_mirror_protocol* m_oscq_protocol{};
48 
49  bool m_zeroconf{true}; // true if we should lookup for device name with zeroconf
50 
51  bool is_zeroconf() const { return m_zeroconf; }
52  std::string get_name() const { return m_name ? std::string(m_name->s_name) : ""; }
53 
54  static void get_mess_cb(client* x, t_symbol* s);
55 
56  static void disconnect(client* x);
57  static void connect(client* x);
58  static void connect_mess_cb(client* x, t_symbol*, int argc, t_atom* argv);
59  static void update(client* x);
60  static void poll_message(client* x);
61  static void destroy(client* x);
62  static void* create(t_symbol* name, int argc, t_atom* argv);
63 
64  int m_argc{};
65  t_atom* m_argv{};
66 };
67 } // namespace