31 , m_socket{oscpack::IpEndpointName(ip.c_str(), port)}
36 template <
typename... Args>
39 send_base(address.get_node().osc_address(), std::forward<Args>(args)...);
41 template <
typename... Args>
44 send_base(address.address, std::forward<Args>(args)...);
47 template <
typename... Args>
48 void send(
const std::string& address, Args&&... args)
50 send_base(address, std::forward<Args>(args)...);
53 template <
typename... Args>
54 void send(std::string_view address, Args&&... args)
56 send_base(address, std::forward<Args>(args)...);
59 const std::string& ip()
const {
return m_ip; }
61 int port()
const {
return m_port; }
63 int localPort()
const {
return m_socket.LocalPort(); }
65 oscpack::UdpTransmitSocket& socket() {
return m_socket; }
68 void debug(
const oscpack::OutboundPacketStream& out)
70 std::string s(out.Data(), out.Data() + out.Size());
71 std::replace(s.begin(), s.end(),
'\0',
' ');
72 std::cerr << s <<
"\n";
75 template <
typename... Args>
76 void send_base(Args&&... args)
78 auto buf = m_pool.acquire();
79 while(buf.size() < ossia::net::max_osc_message_size)
83 oscpack::OutboundPacketStream p{buf.data(), buf.size()};
84 oscpack::osc_message_generator<ValueWriter> generate_message{p};
85 generate_message(std::forward<Args>(args)...);
93 buf.resize(n * 2 + 1);
97 m_pool.release(std::move(buf));
100 std::string format_string;
101 format_string.reserve(5 + 3 *
sizeof...(args));
102 format_string +=
"Out: ";
103 for(std::size_t i = 0; i <
sizeof...(args); i++)
104 format_string +=
"{} ";
109 void send_impl(
const oscpack::OutboundPacketStream& m)
113 m_socket.Send(m.Data(), m.Size());
121 oscpack::UdpTransmitSocket m_socket;
125 ossia::buffer_pool& m_pool = ossia::buffer_pool::instance();