diff --git a/core/IvmiScene.gd b/core/IvmiScene.gd index be13df74409d66fdcf932055fafa2c3098f81491..839dbb7092ed62381c4b4810a0aa5da2a384d16b 100644 --- a/core/IvmiScene.gd +++ b/core/IvmiScene.gd @@ -245,10 +245,7 @@ func _process(delta) : _osc_output_address = peer["address"] _osc_output_port = peer["port"] _osc_to_pd.set_output(_osc_output_address, _osc_output_port) - var local_addr = "127.0.0.1" - for addr in IP.get_local_addresses() : - if not ":" in addr and addr!="127.0.0.1": - local_addr = addr + var local_addr = _osc_to_pd.get_local_address() _osc_to_pd.send_msg("/ivmi/hello_from_gd","sf",[local_addr, _input_port]) PdMode.LIBPD : #libpd mode diff --git a/core/net/GodOSC.gd b/core/net/GodOSC.gd index b04890fdf0bbbcf3451c9e043b40696e2222417e..a631b8fa3b23654fc1618ecc5d971433718d4b34 100644 --- a/core/net/GodOSC.gd +++ b/core/net/GodOSC.gd @@ -44,10 +44,19 @@ func has_msg() : func get_msg() : return _unpack_osc(_socket.get_packet()) - + func get_last_peer() : return {"address":_socket.get_packet_ip(), "port":_socket.get_packet_port()} +func get_local_address() -> String : + var address : String = "127.0.0.1" + + var addrs = IP.get_local_addresses() + for a in addrs : + if a!="127.0.0.1" and not a.contains(":") and not a.begins_with("169.") : + address=a + return address + func _make_osc_string(s,buff) : buff.put_data(s.to_ascii_buffer()) buff.put_u8(0) diff --git a/core/net/IvmiDiscov.gd b/core/net/IvmiDiscov.gd index c80801c40cb9706071ac3f571fe2812d65972349..1d8417565fc002b85589d55f4a6fd592db5b2f05 100644 --- a/core/net/IvmiDiscov.gd +++ b/core/net/IvmiDiscov.gd @@ -31,11 +31,10 @@ func start() : _osc_discov.set_input_port(mcprt) _osc_discov.set_multicast(mcadd) + print(_osc_discov.get_local_address()) + #retrieve local address - _local_addr = "127.0.0.1" - for addr in IP.get_local_addresses() : - if addr!="127.0.0.1" and not ":" in addr : - _local_addr = addr + _local_addr = _osc_discov.get_local_address() func _process(delta) : #when server send ping to multicast