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

WebsocketServerPlugin

Extends:

Plugin → WebsocketServerPlugin

Test:

Constructor Summary

Public Constructor
public

constructor(options: object)

Create an OSC WebsocketServerPlugin instance with given options.

Member Summary

Private Members
private
private
private
private

Method Summary

Public Methods
public

close()

Close Websocket server

public

open(customOptions: object)

Start a Websocket server.

public

send(binary: Uint8Array)

Send an OSC Packet, Bundle or Message to Websocket clients

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

Override:

Plugin#constructor

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.server Server
  • optional

Use existing Node.js HTTP/S server

Example:

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

osc.open() // start server
Using an existing HTTP server
const http = require('http')
const httpServer = http.createServer();
const plugin = new OSC.WebsocketServerPlugin({ 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

Public Methods

public close() source

Close Websocket server

Override:

Plugin#close

public open(customOptions: object) source

Start a Websocket server. Defaults to global options

Override:

Plugin#open

Params:

NameTypeAttributeDescription
customOptions object
  • optional

Custom options

customOptions.host string
  • optional

Hostname of Websocket server

customOptions.port number
  • optional

Port of Websocket server

public send(binary: Uint8Array) source

Send an OSC Packet, Bundle or Message to Websocket clients

Override:

Plugin#send

Params:

NameTypeAttributeDescription
binary Uint8Array

Binary representation of OSC Packet

public status(): number source

Returns the current status of the connection

Override:

Plugin#status

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