PlayerGets whether the user has enabled OSC input.
You can set it from "Enable OSC Receiver" in the "Other" tab of "Settings".
Gets whether the user has enabled OSC output.
You can set it from "Enable OSC Sender" in the "Other" tab of "Settings".
Registers a callback to be called when an OSC message is received.
The callback is called with an array of OscMessage received between the previous frame and the current frame.
If called multiple times, only the last registration is valid.
However, the callback is not called if any of the following conditions are met:
false/cluster/ (reserved by the system)messages: The array of received OSC messages.
// Log the received OSC messages
_.oscHandle.onReceive(messages => {
const lines = [];
messages.forEach((message, i) => {
const { address, timestamp, values } = message;
lines.push(`== message [${i + 1}/${messages.length}]`);
lines.push(`address: ${address}`);
lines.push(`timestamp: ${new Date(timestamp).toLocaleString()}`);
values.forEach((value, j) => {
lines.push(`= value [${j + 1}/${values.length}]`);
lines.push(`getInt(): ${value.getInt()}`);
lines.push(`getFloat(): ${value.getFloat()}`);
lines.push(`getAsciiString(): ${value.getAsciiString()}`);
lines.push(`getBlobAsUint8Array(): ${value.getBlobAsUint8Array()}`);
lines.push(`getBlobAsUtf8String(): ${value.getBlobAsUtf8String()}`);
lines.push(`getBool(): ${value.getBool()}`);
});
});
_.log(lines.join("\n"));
});
Attempts to send an OSC bundle or an OSC message.
If any of the following conditions are met, a ClusterScriptError will occur and the bundle or message will fail to be sent.
false//cluster/ (reserved by the system)Due to the nature of the OSC system, there is no guarantee that the data you send will reach the destination server.
The bundle or message to be sent
// Send various OSC bundles and OSC messages
_.oscHandle.send(new OscBundle([new OscMessage("/int", [OscValue.int(1)])]));
_.oscHandle.send(new OscMessage("/float", [OscValue.float(2.3)]));
_.oscHandle.send(new OscMessage("/string", [OscValue.asciiString("456")]));
_.oscHandle.send(new OscMessage("/blob", [OscValue.blob("789")]));
_.oscHandle.send(new OscMessage("/bool", [OscValue.bool(false)]));
The handle to receive or send Open Sound Control (OSC) messages. This handle can be obtained by PlayerScript.oscHandle.
For more information about OSC, please also refer to the OSC section in the documentation.