EventHandler
Test:
Constructor Summary
Public Constructor | ||
public |
constructor(options: object) Create an EventHandler instance |
Method Summary
Public Methods | ||
public |
Notify the EventHandler of incoming OSC messages or status changes (open, close, error). |
|
public |
Unsubscribe listener from event notification or address handler |
|
public |
Subscribe to a new address or event you want to listen to |
Private Methods | ||
private |
Internally used method to invoke listener callbacks. |
|
private |
Internally used method to dispatch OSC Packets. |
Public Constructors
Public Methods
public notify(args: ...*): boolean source
Notify the EventHandler of incoming OSC messages or status changes (open, close, error). Handles OSC address patterns and executes timed messages. Use binary arrays when handling directly incoming network data. Packet's or Messages can also be used
Params:
Name | Type | Attribute | Description |
args | ...* | The OSC address pattern / event name as string}. For convenience and Plugin API communication you can also use Message or Packet instances or ArrayBuffer, Buffer instances (low-level access). The latter will automatically be unpacked When using a string you can also pass on data as a second argument (any type). All regarding listeners will be notified with this data. As a third argument you can define a javascript timestamp (number or Date instance) for timed notification of the listeners. |
Example:
const socket = dgram.createSocket('udp4')
socket.on('message', (message) => {
this.notify(message)
})
this.notify('error', error.message)
const message = new OSC.Message('/test/path', 55)
this.notify(message)
const message = new OSC.Message('/test/path', 55)
// override timestamp
this.notify(message.address, message, Date.now() + 5000)
Test:
public off(name: string, subscriptionId: number): boolean source
Unsubscribe listener from event notification or address handler
Test:
public on(name: string, callback: function): number source
Subscribe to a new address or event you want to listen to
Test:
Private Methods
private call(name: string, data: *, rinfo: *): boolean source
Internally used method to invoke listener callbacks. Uses regular expression pattern matching for OSC addresses
Params:
Name | Type | Attribute | Description |
name | string | OSC address or event name |
|
data | * |
|
The data of the event |
rinfo | * |
|
Remote address info |