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

WebsocketClientPlugin

Test:

Constructor Summary

Public Constructor
public

constructor(options: object)

Create an OSC WebsocketClientPlugin instance with given options.

Member Summary

Private Members
private
private
private
private

Method Summary

Public Methods
public

close()

Close Websocket

public

open(customOptions: object)

Connect to a Websocket server.

public

send(binary: Uint8Array)

Send an OSC Packet, Bundle or Message to Websocket server

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 WebsocketClientPlugin instance with given options. Defaults to localhost:8080 for connecting to a Websocket server

Params:

NameTypeAttributeDescription
options object
  • optional

Custom options

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

Hostname of Websocket server

options.port number
  • optional
  • default: 8080

Port of Websocket server

options.secure boolean
  • optional
  • default: false

Use wss:// for secure connections

Example:

const plugin = new OSC.WebsocketClientPlugin({ 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 Websocket

public open(customOptions: object) source

Connect to a Websocket server. Defaults to global options

Params:

NameTypeAttributeDescription
customOptions object
  • optional

Custom options

customOptions.host string
  • optional

Hostname of Websocket server

customOptions.port number
  • optional

Port of Websocket server

customOptions.secure boolean
  • optional

Use wss:// for secure connections

public send(binary: Uint8Array) source

Send an OSC Packet, Bundle or Message to Websocket server

Params:

NameTypeAttributeDescription
binary Uint8Array

Binary representation of OSC Packet

public status(): number source

Returns the current status of the connection

Return:

number

Status identifier

Private Methods

private registerNotify(fn: function) source

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

Params:

NameTypeAttributeDescription
fn function

Notify callback