You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
775 B
JavaScript

7 months ago
const serverAddress = '192.168.2.1'; // Replace with the OSC server's IP address
const serverPort = 8080; // Replace with the OSC server's port
function sendOSCMessage(address, data) {
const message = createOSCMessage(address, data);
const socket = new WebSocket(`ws://${serverAddress}:${serverPort}`);
socket.addEventListener('open', () => {
socket.send(message);
console.log('WebSocket message sent successfully');
});
socket.addEventListener('error', (error) => {
console.error('Error with WebSocket connection:', error);
});
}
function createOSCMessage(address, data) {
// Create an OSC message based on the address and data
// Return the serialized OSC message as a string
}
// Example usage
sendOSCMessage('/my/message', 'Hello, OSC!');