master
louisa 1 year ago
parent 87f9fba5d3
commit d3714bbfd4

@ -0,0 +1,37 @@
const express = require('express');
const osc = require('osc-min');
const dgram = require('dgram');
const app = express();
const oscHost = '192.168.2.1'; // IP address of the OSC destination
const oscPort = 8000; // Port number of the OSC destination
app.get('/trigger-blink', (req, res) => {
// Create the OSC message
const oscMessage = osc.toBuffer({
address: '/blink',
args: [1]
});
// Create a UDP socket
const udpSocket = dgram.createSocket('udp4');
// Send the OSC message
udpSocket.send(oscMessage, 0, oscMessage.length, oscPort, oscHost, (err) => {
if (err) {
console.error('Error sending OSC message:', err);
res.status(500).send('Error sending OSC message');
} else {
console.log('OSC message sent successfully');
res.send('OSC message sent successfully');
}
// Close the UDP socket
udpSocket.close();
});
});
// Start the server
app.listen(8000, () => {
console.log('Server is running on port 8000');
});
Loading…
Cancel
Save