rob
rc 2022-03-05 15:31:22 +01:00
parent f0d95ecb9d
commit 579506e4c5
1 changed files with 13 additions and 10 deletions

View File

@ -1,4 +1,4 @@
cconsonst express = require('express')
const express = require('express')
const http = require('http')
const WebSocket = require('ws')
const osc = require('osc')
@ -30,7 +30,7 @@ const include_files = [
const app = express();
const server = http.Server(app);
const DEBUG = false
const DEBUG = true
// Odprti serijski OSC link
let scon = null
@ -62,7 +62,7 @@ function openSerial() {
scon.on('message', msg => {
// Debug incoming osc
if (DEBUG) {
//console.log('osc msg', msg)
console.log('osc msg', msg)
}
sendAll(msg, null, null, osclients)
@ -110,15 +110,17 @@ const wss = new WebSocket.Server({ server })
// Relay multicast to websockets
// @TODO still sends to supercollider? Do we need two sockets?
var dgram = require('dgram');
var sss = dgram.createSocket('udp4');
sss.on('listening', () => {
sss.addMembership('224.0.1.9');
})
sss.bind(6696, '224.0.1.9');
//var dgram = require('dgram');
//var sss = dgram.createSocket('udp4');
//sss.on('listening', () => {
// sss.addMembership('224.0.1.9');
//})
//sss.bind(57120);
const scudp = new osc.UDPPort({
socket: sss
//socket: sss
remotePort: 57121,
localPort: 57100
})
scudp.on('open', () => {
@ -206,6 +208,7 @@ const sendAll = (msg, info, oscWS, osclients) => {
})
if (scudp) {
console.log("SENDING UDP", msg)
scudp.send(msg)
}
}