main
Jurij Podgoršek 7 months ago
parent 40d869c098
commit 0272c5851f
  1. 30
      server.js

@ -7,7 +7,8 @@ const PORT = 6676
// Do we have a problem, shall we debug?
const DEBUG = {
osc: true,
udp: false
udp: false,
midi: true
}
// MIDI out
@ -246,12 +247,6 @@ const sendAll = (msg, info, oscWS, osclients) => {
}, info, oscWS, osclients)
}
if (MIDI) {
if (msg.address == '/midi') {
mo.send(msg.args)
}
}
osclients.forEach( client => {
if (client && oscWS != client) {
// console.log("sending", msg, info)
@ -270,16 +265,23 @@ const sendAll = (msg, info, oscWS, osclients) => {
let osclients = []
wss.on('connection', function (ws) {
console.log('new client connection')
console.log('new client connection', ws._socket.remoteAddress)
let oscWS = new osc.WebSocketPort({
socket: ws,
metadata: false
socket: ws
});
// Vsi OSC sem grejo naprej na kliente OSC
oscWS.on('packet', (packet, info) => {
// Broadcast adjust msg
const [address, args] = packet
oscWS.on('message', ({ address, args}, info) => {
console.log('fasal sem', address, args)
if (MIDI) {
if (address == '/midi') {
if (DEBUG.midi) {
console.log('midi SEND', args)
}
mo.send(args)
}
}
sendAll({ address, args}, info, oscWS, osclients)
})
@ -292,7 +294,7 @@ wss.on('connection', function (ws) {
osclients.push(oscWS)
oscWS.on('close', () => {
console.log('closing socket', oscWS)
console.log('closing socket', oscWS.socket.remoteAddress)
osclients = osclients.filter(ws => ws !== oscWS)
})
})

Loading…
Cancel
Save