OSSIA
Open Scenario System for Interactive Application
ossia-pd/src/device.hpp
1 #pragma once
2 #include "device_base.hpp"
3 #include "m_pd.h" // for post()
4 
5 namespace ossia::pd
6 {
7 
8 namespace Protocol_Settings
9 {
10 struct minuit
11 {
12  std::string remoteip{"localhost"};
13  unsigned int remoteport = 13579;
14  unsigned int localport = 9998;
15 };
16 
17 struct oscquery
18 {
19  unsigned int oscport = 9999;
20  unsigned int wsport = 5678;
21 };
22 
23 struct osc
24 {
25  std::string remoteip{"localhost"};
26  unsigned int remoteport = 9997;
27  unsigned int localport = 9996;
28 };
29 
30 static void print_protocol_help()
31 {
32  post("expose <protocol> <args> ...");
33  post("Available protocols (case sensitive): Minuit, oscquery, osc");
34  post("Protocols parameters :");
35  post(
36  "Minuit <remoteip> <remoteport> <localport> :\n"
37  "\tremoteip (symbol): ip of target device\n"
38  "\tremoteport (float): port on which packet should be send\n"
39  "\tlocalport (float): port to which this device is listening\n"
40  "\tdefault sending on port 13579, listening on 9998");
41  post(
42  "oscquery <oscport> <wsport> :\n"
43  "\toscport (float) : port on which osc packet are sent\n"
44  "\twsport (float) : WebSocket port on which distant application will "
45  "connect.\n"
46  "\tdefault ports: OSC 9999, WebSocket 5678");
47  post(
48  "osc <remoteip> <remoteport> <localpoort>\n"
49  "\tremoteip (symbol): ip of target device\n"
50  "\tremoteport (float): port on which packet should be send\n"
51  "\tlocalport (port): port this device is listening.\n"
52  "\tdefault sending on port 9997, listening on 9996");
53 }
54 }
55 
56 class device : public device_base
57 {
58 public:
59  device();
60 
61  using is_device = std::true_type;
62 
63  static void register_children(device* x);
64  void unregister_children();
65  static void loadbang(device* x, t_float type);
66 
67  std::vector<std::vector<t_atom>> m_protocols{};
68 
69  static void* create(t_symbol* name, int argc, t_atom* argv);
70  static void destroy(device* x);
71  static void expose(device* x, t_symbol*, int argc, t_atom* argv);
72  static void name(device* x, t_symbol*, int argc, t_atom* argv);
73  static void get_mess_cb(device* x, t_symbol* s);
74  static void get_protocols(device* x);
75  static void get_oscq_clients(device* x);
76  static void stop_expose(device* x, float index);
77 };
78 
79 } // namespace