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

DatagramPlugin

OSC plugin for simple OSC messaging via udp client and udp server

Test:

Constructor Summary

Public Constructor
public

constructor(options: object)

Create an OSC Plugin instance with given options.

Member Summary

Private Members
private
private
private
private

Method Summary

Public Methods
public

close()

Close udp socket

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

Public Constructors

public constructor(options: object) source

Create an OSC Plugin instance with given options. Defaults to localhost:41234 for server and localhost:41235 for client messaging

Params:

NameTypeAttributeDescription
options object
  • optional

Custom options

options.type string
  • optional
  • default: 'udp4'

'udp4' or 'udp6'

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

Hostname of udp server to bind to

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

Port of udp server to bind to

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

Exclusive flag

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

Hostname of udp client for messaging

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

Port of udp client for messaging

Example:

const plugin = new OSC.DatagramPlugin({ send: { port: 9912 } })
const osc = new OSC({ plugin: plugin })

Private Members

private notify: function source

private options: object source

private socket: object source

private socketStatus: number source

Public Methods

public close() source

Close udp socket

public open(customOptions: object) source

Bind a udp socket to a hostname and port

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 port and hostname, otherwise the global options will be taken

Params:

NameTypeAttributeDescription
binary Uint8Array

Binary representation of OSC Packet

customOptions object
  • optional

Custom options for udp socket

customOptions.host string
  • optional

Hostname of udp client

customOptions.port number
  • optional

Port of udp client

public status(): number source

Returns the current status of the connection

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