From 954b35032ab8d23ff13e51fcdf9cef49b8b9e765 Mon Sep 17 00:00:00 2001 From: brunoherbelin Date: Sun, 1 Nov 2020 15:11:26 +0100 Subject: [PATCH] Fix Connection broadcaster --- Connection.cpp | 48 +++++++++++++++++++++++------------------------- Connection.h | 2 -- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/Connection.cpp b/Connection.cpp index 3ad847b..73de99f 100644 --- a/Connection.cpp +++ b/Connection.cpp @@ -161,22 +161,15 @@ void Connection::ask() p << Connection::manager().connections_[0].port_handshake; p << osc::EndMessage; - // broadcast on several ports, except myself - std::vector handshake_ports; - for(int i=HANDSHAKE_PORT; iAsInt32(); - // build message - char buffer[IP_MTU_SIZE]; - osc::OutboundPacketStream p( buffer, IP_MTU_SIZE ); - p.Clear(); - p << osc::BeginMessage( OSC_PREFIX OSC_PONG ); - p << Connection::manager().connections_[0].name.c_str(); - p << Connection::manager().connections_[0].port_handshake; - p << Connection::manager().connections_[0].port_stream_request; - p << Connection::manager().connections_[0].port_osc; - p << osc::EndMessage; + // ignore requests from myself + if ( !NetworkToolkit::is_host_ip(remote_ip) + || Connection::manager().connections_[0].port_handshake != remote_port) { - // send OSC message to port indicated by remote - IpEndpointName host( remote_ip.c_str(), remote_port ); - UdpTransmitSocket socket( host ); - socket.Send( p.Data(), p.Size() ); + // build message + char buffer[IP_MTU_SIZE]; + osc::OutboundPacketStream p( buffer, IP_MTU_SIZE ); + p.Clear(); + p << osc::BeginMessage( OSC_PREFIX OSC_PONG ); + p << Connection::manager().connections_[0].name.c_str(); + p << Connection::manager().connections_[0].port_handshake; + p << Connection::manager().connections_[0].port_stream_request; + p << Connection::manager().connections_[0].port_osc; + p << osc::EndMessage; + // send OSC message to port indicated by remote + IpEndpointName host( remote_ip.c_str(), remote_port ); + UdpTransmitSocket socket( host ); + socket.Send( p.Data(), p.Size() ); + + } } // pong response: add info else if( std::strcmp( m.AddressPattern(), OSC_PREFIX OSC_PONG) == 0 ){ diff --git a/Connection.h b/Connection.h index ac56d2a..3ad5296 100644 --- a/Connection.h +++ b/Connection.h @@ -83,8 +83,6 @@ public: private: - std::string hostname_; - static void ask(); static void listen(); ConnectionRequestListener listener_;