Home Reference Source Test
import BridgePlugin from 'osc-js/src/plugin/bridge.js'
public class | source

BridgePlugin

Extends:

Plugin → BridgePlugin

OSC plugin for setting up communication between a Websocket client and a udp client with a bridge inbetween

Test:

Constructor Summary

Public Constructor
public

constructor(options: object)

Create an OSC Bridge instance with given options.

Member Summary

Private Members
private
private
private
private
private

Method Summary

Public Methods
public

close()

Close udp socket and Websocket server

public

open(customOptions: object)

Bind a udp socket to a hostname and port

public

send(binary: Uint8Array, customOptions: object)

Send an OSC Packet, Bundle or Message.

public

Returns the current status of the connection

Private Methods
private

Internal method to hook into osc library's EventHandler notify method

Inherited Summary

From class Plugin
public

close()

Close socket connection and anything else used in the implementation.

public

open(customOptions: object)

Open socket connection.

public

send(binary: Uint8Array, customOptions: object)

Send an OSC Packet, Bundle or Message.

public

Returns the current status of the connection

Public Constructors

public constructor(options: object) source

Create an OSC Bridge instance with given options. Defaults to localhost:41234 for udp server, localhost:41235 for udp client and localhost:8080 for Websocket server

Override:

Plugin#constructor

Params:

NameTypeAttributeDescription
options object
  • optional

Custom options

options.udpServer.host string
  • optional
  • default: 'localhost'

Hostname of udp server to bind to

options.udpServer.port number
  • optional
  • default: 41234

Port of udp server to bind to

options.udpServer.exclusive boolean
  • optional
  • default: false

Exclusive flag

options.udpClient.host string
  • optional
  • default: 'localhost'

Hostname of udp client for messaging

options.udpClient.port number
  • optional
  • default: 41235

Port of udp client for messaging

options.wsServer.host string
  • optional
  • default: 'localhost'

Hostname of Websocket server

options.wsServer.port number
  • optional
  • default: 8080

Port of Websocket server

options.wsServer.server http.Server | https.Server
  • optional

Use existing Node.js HTTP/S server

options.receiver string
  • optional
  • default: 'ws'

Where messages sent via 'send' method will be delivered to, 'ws' for Websocket clients, 'udp' for udp client

Example:

const plugin = new OSC.BridgePlugin({ wsServer: { port: 9912 } })
const osc = new OSC({ plugin: plugin })
Using an existing HTTP server
const http = require('http')
const httpServer = http.createServer();
const plugin = new OSC.BridgePlugin({ wsServer: { server: httpServer } })
const osc = new OSC({ plugin: plugin })

Private Members

private notify: function source

private options: object source

private socket: object source

private socketStatus: number source

private websocket: object source

Public Methods

public close() source

Close udp socket and Websocket server

Override:

Plugin#close

public open(customOptions: object) source

Bind a udp socket to a hostname and port

Override:

Plugin#open

Params:

NameTypeAttributeDescription
customOptions object
  • optional

Custom options

customOptions.host string
  • optional
  • default: 'localhost'

Hostname of udp server to bind to

customOptions.port number
  • optional
  • default: 41234

Port of udp server to bind to

customOptions.exclusive boolean
  • optional
  • default: false

Exclusive flag

public send(binary: Uint8Array, customOptions: object) source

Send an OSC Packet, Bundle or Message. Use options here for custom receiver, otherwise the global options will be taken

Override:

Plugin#send

Params:

NameTypeAttributeDescription
binary Uint8Array

Binary representation of OSC Packet

customOptions object
  • optional

Custom options

customOptions.udpClient.host string
  • optional
  • default: 'localhost'

Hostname of udp client for messaging

customOptions.udpClient.port number
  • optional
  • default: 41235

Port of udp client for messaging

customOptions.receiver string
  • optional
  • default: 'ws'

Messages will be delivered to Websocket ('ws') clients or udp client ('udp')

public status(): number source

Returns the current status of the connection

Override:

Plugin#status

Return:

number

Status ID

Private Methods

private registerNotify(fn: function) source

Internal method to hook into osc library's EventHandler notify method

Params:

NameTypeAttributeDescription
fn function

Notify callback