Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions backend/main.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { Server } from 'socket.io';
import ConnectionManager from './ulxd/connectionmanager';
import { ClientSentEvents, ServerSentEvents } from '../shared/socketevents';
import OSC from 'osc';

const io = new Server<ClientSentEvents, ServerSentEvents>();
const osc = new OSC.UDPPort({
localAddress: '0.0.0.0',
localPort: '51331',
});

io.listen(3000, {
cors: {
Expand All @@ -11,6 +16,11 @@ io.listen(3000, {
},
});

osc.open();
osc.on('ready', () => {
console.log('OSC server listening on :51331');
});

console.log('socket.io server listing');

const connectionManager = new ConnectionManager(io);
Expand All @@ -32,6 +42,18 @@ io.on('connection', (socket) => {
connectionManager.deregisterSocket(socket);
});

socket.on('OSC_SEND', (deviceIP, port, path, args) => {
console.log(`Sending OSC to ${deviceIP}:${port} ${path} ${args}`);
osc.send(
{
address: path,
args: args,
},
deviceIP,
port,
);
});

// socket.on('GAIN', (device, gain) => {
// setDeviceGain(device, gain);
// });
Expand Down
Loading