colinbdclark / osc.js-examples

Sample code illustrating how to use osc.js in a variety of scenarios.
104 stars 28 forks source link

[QUESTION] Is it possible to send Multicast OSC messages? #16

Closed trafalmejo closed 4 years ago

trafalmejo commented 4 years ago

Hi all, Thanks, this library is quite handy. I am working on sending OSC messages to multiple devices with different IPs and ports. I saw you have an example of listening from multiple hosts using UDPPort. How can use UDPPort to send several messages to different devices connected to the same network? Thanks

colinbdclark commented 4 years ago

Hi @trafalmejo,

I'm not 100% I understand your use case, but I think I might know what you mean. Are you interested in using broadcast UDP for sending to multiple clients? If so, there's a broadcast flag that is an option for the UDPPort object that you can set.

Or if you're wanting to send messages to multiple individual clients who are listening on different ports, you'll need to have one UDPPort per client and send your message to each of them.

I hope this helps!

trafalmejo commented 4 years ago

Thanks, Actually I was able to multicast (sending multiple messages to different hosts) from only one UDPort.

var udpPortLocal = new osc.UDPPort({
    localAddress: "localhost",
    localPort: process.env.LANPORT,
    metadata: true,
});
udpPortLocal.open()
udpPortLocal.send(msg, ip, port);