-
Notifications
You must be signed in to change notification settings - Fork 0
/
oscServer.js
40 lines (36 loc) · 1.5 KB
/
oscServer.js
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
35
36
37
38
39
40
const fs = require('fs');
const https = require('https');
const OSC = require('osc-js');
const os = require('os');
const server = https.createServer({
host: '0.0.0.0',
cert: fs.readFileSync('./certificate.crt'),
key: fs.readFileSync('./privatekey.key')
});
// const { address } = os.networkInterfaces().Ethernet.find(({family}) => family === 'IPv4');
const wsPort = 8080;
const udpPort = 41234;
const osc = new OSC({
plugin: new OSC.BridgePlugin({
receiver: 'ws', // @param {string} Where messages sent via 'send' method will be delivered to, 'ws' for Websocket clients, 'udp' for udp client
udpServer: {
host: 'localhost', // @param {string} Hostname of udp server to bind to
port: udpPort, // @param {number} Port of udp server to bind to
exclusive: false // @param {boolean} Exclusive flag
},
udpClient: {
host: 'localhost', // @param {string} Hostname of udp client for messaging
port: 41235 // @param {number} Port of udp client for messaging
},
wsServer: {
// host: '0.0.0.0', // @param {string} Hostname of WebSocket server
// port: wsPort, // @param {number} Port of WebSocket server
server, // FIXME: had to modify WebSocketServer plugin to accept this option. maybe ditch osc-js or fork it
}
})
})
server.listen(wsPort);
osc.open() // start a WebSocket server on port 8080
// console.log(`listening at ${address}`)
console.log(`WS Port ${wsPort}`)
console.log(`UDP Port ${udpPort}`)