blob: 0ef4ea873540f37d82a8d29ebf14aea4c68ec35c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
const UDP_PORT = 49160
const OSC_PORT = 49162
const dgram = require('dgram');
const udpserver = dgram.createSocket('udp4');
const osc = require('./desktop/node_modules/node-osc')
const oscserver = new osc.Server(OSC_PORT, '127.0.0.1')
console.log(`Started Listener\n\nUDP:${UDP_PORT}\nOSC:${OSC_PORT}\n`)
// Error
udpserver.on('error', (err) => {
console.log(`UDP server:\n${err.stack}`);
udpserver.close();
})
oscserver.on('error', (err) => {
console.log(`OSC server:\n${err.stack}`);
oscserver.close();
})
// Message
udpserver.on('message', (msg, rinfo) => {
console.log(`UDP server: ${msg} from ${rinfo.address}:${rinfo.port}`);
})
oscserver.on('message', (msg, rinfo) => {
console.log(`OSC server: ${msg} from ${rinfo.address}:${rinfo.port} at /${msg[0]}`)
})
udpserver.bind(UDP_PORT)
|