Azure / azure-webpubsub

Azure Web PubSub Service helps you to manage WebSocket connections and do publish and subscribe in an easy way
https://azure.github.io/azure-webpubsub/
MIT License
132 stars 82 forks source link

OSC support #340

Open brucelane opened 2 years ago

brucelane commented 2 years ago

OSC support

Hello, I'm using software which support OSC, but not websockets.

I think that OSC is quite near websockets, would it be possible to add support for it?

Thank you, Bruce

vicancy commented 2 years ago

Do you mean OpenSoundControl? By reading this spec, OSC defines the protocol of the data but does not restrict the transport type, looks like both UDP and TCP are supported. Which transport are you using?

Also, could you help us understand more about your scenarios using OSC? Do you expect the service REST APIs to support sending messages to your OSC clients? Do you expect event handlers to understand OSC clients' lifetime events and have webhooks to handle these events?

brucelane commented 2 years ago

Yes, OpenSoundControl. For the moment I created a nodejs gateway which is on the same pc as the OSC Receiver in the VJ software: it's a websocket server using the ws npm module, each ws message received is sent as an OSC message with osc npm module. It works fine, but it's an extra step. I uses UDP in my case. Here is a code snippet:

let WebSocketServer = require('ws').Server;
const osc = require('osc');
const udpPort = new osc.UDPPort({
  localAddress: "127.0.0.1",
  localPort: 57121,
  remoteAddress: "127.0.0.1",
  remotePort: 2346,
  metadata: true
});
// Open the socket.
udpPort.open();
// When a ws message is received, name and value are parsed from it and sent to OSC via:
let message = {
  address: "/message",
  args: [
    {
      type: "i",
      value: name
     }, {
    type: "f",
    value: value
    }
  ]
 };
udpPort.send(message);

The VJ software is for instance SMODE and here is its OSC configuration:

deviceIdentifier = => 'SocketDeviceIdentifier @15d98bb36e1b232f 
      {
        factory = "OSC", 
        localInput = {localIp = "0.0.0.0", localPort = 2346}, 
        send = false, 
        remoteOutput = {host = "255.255.255.255", port = 13000}
      }, 

I would expect the service REST APIs to support sending messages to my OSC clients directly, but I don't think it's possible. The REST API could receive the OSC messages though, that would be useful. Thanks for your time.