MylesBorins / node-osc

Open Sound Control protocol library for Node.js
GNU Lesser General Public License v3.0
435 stars 72 forks source link

Experimental Bundles #48

Closed MylesBorins closed 3 years ago

MylesBorins commented 3 years ago

This PR adds "experimental" support for processing OSC Bundle.

There is a new type of event on the osc Server called "bundle" that will get called with a decoded bundle when the OSC Server receives a bundle. It is possible for bundles to be recursive. There is currently no logic for processing a bundle as a series of messages.

import { Server } from 'node-osc';

var oscServer = new Server(3333, '0.0.0.0', () => {
  console.log('OSC Server is listening');
});

oscServer.on('bundle', function (bundle) {
  bundle.elements.forEach((element, i) => {
    console.log(`Timestamp: ${bundle.timetag[i]}`);
    console.log(`Message: ${element}`)
  });
  oscServer.close();
});

This PR also refactors the internals fairly significantly to have the Server now use osc-min rather than manually decoded packets using jspack. This allows us to drop support for the jspack dependency and get Bundle support for free 🎉. This changes some internal errors and as such I am cautiously marking this PR as Semver-Major.