Skip to content

Bridge Plugin

Andreas Dzialocha edited this page Jan 12, 2017 · 4 revisions

Basic setup

BridgePlugin for building a link between applications inside the browser and other applications who are not capable of WebSocket networking (for example Max/MSP).

const osc = new OSC({ plugin: new OSC.BridgePlugin() })
osc.open()

Options

The options can be passed on inside the constructor. The open or send message can also take individual options. This will then override the globally set options for their regarding methods.

{
  receiver: 'ws',         // @param {string} Where messages sent via 'send' method will be delivered to, 'ws' for Websocket clients, 'udp' for udp client
  udpServer: {
    host: 'localhost',    // @param {string} Hostname of udp server to bind to
    port: 41234,          // @param {number} Port of udp server to bind to
    exclusive: false      // @param {boolean} Exclusive flag
  },
  udpClient: {
    host: 'localhost',    // @param {string} Hostname of udp client for messaging
    port: 41235           // @param {number} Port of udp client for messaging
  },
  wsServer: {
    host: 'localhost',    // @param {string} Hostname of WebSocket server
    port: 8080            // @param {number} Port of WebSocket server
  }
}

Examples

const options = {
  udpServer: {
    port: 9912
  }
}

const osc = new OSC({ plugin: new OSC.BridgePlugin(options) })
osc.open()
const osc = new OSC({ plugin: new OSC.BridgePlugin() })
osc.open()

osc.send(new OSC.Message('/test'), { receiver: 'udp' }) // send only this message to udp client

Further reading

  • Example: How to build a bridge server for WebSocket/UDP with osc-js to talk to Max/MSP, PureData etc from the browser.
  • Documentation: Read about the BridgePlugin class here.