OSC Controller module
This module provides functionality for communication to and from the server over Open Sound Control.
Members
(static) eventEmitter :EventEmitter
This EventEmitter emits OSC-related events. Consumers can listen here
to be notified when OSC messages are sent or received.
Type:
- EventEmitter
Fires:
(static) incomingPort :number
The port over which OSC messages will be received.
Type:
- number
(static) outgoingHost :string
The hostname of the host to which OSC messages will be sent.
Type:
- string
(static) outgoingPort :number
The port over which OSC messages will be sent.
Type:
- number
Methods
(static) closeSockets() → {undefined}
Close both the incoming socket and the outgoing socket.
Returns:
- Type
- undefined
(static) init(callback)
Initialize the module.
This method first ensures that both sockets are closed, then opens each socket on the ports specified in outgoingPort and incomingPort.
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
function | Will be called after initialization is complete |
(static) sendJSONMessage(data, callback) → {undefined}
Sends an object over OSC.
The object to be sent must match the requirements for an OSC message or bundle as specified by osc-min. The message will be sent to the host in outgoingHost on the port in outgoingPort.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | The object to be sent over OSC |
callback |
function | The function to be called after the message has been sent |
Returns:
- Type
- undefined
(static) sendMessage(req, res) → {undefined}
Sends an object from an http.ClientRequest params over OSC.
The object to be sent must match the requirements for an OSC message or bundle as specified by osc-min. The message will be sent to the host in outgoingHost on the port in outgoingPort. The response is augmented to include the message that was sent.
Parameters:
| Name | Type | Description |
|---|---|---|
req |
http.ClientRequest | The client request |
res |
http.ServerResponse | The server response |
Returns:
- Type
- undefined
Events
oscMessageReceived
This event is fired when the server receives an OSC message.
The object sent with this event is a JavaScript object representation of the OSC message.
Type:
- Object