Comparing version 6.0.0-rc.0 to 6.0.0-rc.1
@@ -6,2 +6,3 @@ 'use strict'; | ||
var Message = require('./Message.js'); | ||
var Bundle = require('./Bundle.js'); | ||
var Server = require('./Server.js'); | ||
@@ -13,3 +14,4 @@ var Client = require('./Client.js'); | ||
exports.Message = Message; | ||
exports.Bundle = Bundle; | ||
exports.Server = Server; | ||
exports.Client = Client; |
'use strict'; | ||
var oscMin = require('osc-min'); | ||
var warnings = require('#internal/warnings'); | ||
let warned = false; | ||
function sanitizeMessage(decoded) { | ||
@@ -27,6 +26,3 @@ const message = []; | ||
if (decoded.oscType === 'bundle') { | ||
if (!warned) { | ||
warned = true; | ||
process.emitWarning('Support for OSC Bundles is experimental and subject to change at any point.'); | ||
} | ||
warnings.bundleWarning(); | ||
return sanitizeBundle(decoded); | ||
@@ -33,0 +29,0 @@ } |
'use strict'; | ||
var dgram = require('dgram'); | ||
var osc = require('osc-min'); | ||
var tap = require('tap'); | ||
@@ -9,80 +7,84 @@ var nodeOsc = require('node-osc'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
tap.beforeEach(util.bootstrap); | ||
var osc__default = /*#__PURE__*/_interopDefaultLegacy(osc); | ||
tap.test('bundle: verbose bundle', (t) => { | ||
const server = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
tap.beforeEach(util.bootstrap); | ||
t.plan(2); | ||
tap.test('bundle: simple bundle', (t) => { | ||
t.plan(1); | ||
t.teardown(() => { | ||
oscServer.close(); | ||
socket.close(); | ||
server.close(); | ||
client.close(); | ||
}); | ||
const payload = { | ||
timetag: 1, | ||
elements: [ | ||
{ | ||
address: '/heartbeat', | ||
args: [ | ||
123 | ||
] | ||
} | ||
server.on('bundle', (bundle) => { | ||
t.same(bundle.elements[0], ['/one', 1]); | ||
t.same(bundle.elements[1], ['/two', 2]); | ||
}); | ||
client.send(new nodeOsc.Bundle(1, { | ||
address: '/one', | ||
args: [ | ||
1 | ||
] | ||
}; | ||
}, { | ||
address: '/two', | ||
args: [ | ||
2 | ||
] | ||
})); | ||
}); | ||
const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
const socket = dgram.createSocket({ | ||
type: 'udp4', | ||
reuseAddr: true | ||
tap.test('bundle: array syntax', (t) => { | ||
const server = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
t.plan(2); | ||
t.teardown(() => { | ||
server.close(); | ||
client.close(); | ||
}); | ||
oscServer.on('bundle', (bundle) => { | ||
t.same(bundle.elements[0], ['/heartbeat', 123]); | ||
server.on('bundle', (bundle) => { | ||
t.same(bundle.elements[0], ['/one', 1]); | ||
t.same(bundle.elements[1], ['/two', 2]); | ||
}); | ||
const buf = osc__default['default'].toBuffer(payload); | ||
socket.send(buf, 0, buf.length, t.context.port, '127.0.0.1'); | ||
client.send(new nodeOsc.Bundle( | ||
['/one', 1], | ||
['/two', 2] | ||
)); | ||
}); | ||
tap.test('bundle: nested bundle', (t) => { | ||
t.plan(1); | ||
const server = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
t.plan(4); | ||
t.teardown(() => { | ||
oscServer.close(); | ||
socket.close(); | ||
server.close(); | ||
client.close(); | ||
}); | ||
const payload = { | ||
timetag: 1, | ||
elements: [{ | ||
timetag: 1, | ||
elements: [ | ||
{ | ||
address: '/heartbeat', | ||
args: [ | ||
123 | ||
] | ||
} | ||
] | ||
}] | ||
}; | ||
const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
const payload = new nodeOsc.Bundle( | ||
['/one', 1], | ||
['/two', 2], | ||
['/three', 3] | ||
); | ||
const socket = dgram.createSocket({ | ||
type: 'udp4', | ||
reuseAddr: true | ||
}); | ||
payload.append(new nodeOsc.Bundle(10, | ||
['/four', 4] | ||
)); | ||
oscServer.on('bundle', (bundle) => { | ||
t.same(bundle.elements[0].elements[0], ['/heartbeat', 123]); | ||
server.on('bundle', (bundle) => { | ||
t.same(bundle.elements[0], ['/one', 1]); | ||
t.same(bundle.elements[1], ['/two', 2]); | ||
t.same(bundle.elements[2], ['/three', 3]); | ||
t.same(bundle.elements[3].elements[0], ['/four', 4]); | ||
}); | ||
const buf = osc__default['default'].toBuffer(payload); | ||
socket.send(buf, 0, buf.length, t.context.port, '127.0.0.1'); | ||
client.send(payload); | ||
}); |
@@ -43,3 +43,3 @@ 'use strict'; | ||
tap.test('client: with object', (t) => { | ||
tap.test('client: with Message object', (t) => { | ||
const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
@@ -70,2 +70,28 @@ const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
tap.test('client: with Bundle object', (t) => { | ||
const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
t.plan(2); | ||
oscServer.on('message', (msg) => { | ||
oscServer.close(); | ||
t.same(msg, ['/test', 1, 2, 3, 'lol', false], `we received the payload: ${msg}`); | ||
}); | ||
client.send({ | ||
address: '/test', | ||
args: [ | ||
1, | ||
2, | ||
3, | ||
'lol', | ||
false | ||
] | ||
}, (err) => { | ||
t.error(err, 'there should be no error'); | ||
client.close(); | ||
}); | ||
}); | ||
tap.test('client: failure', (t) => { | ||
@@ -72,0 +98,0 @@ const client = new nodeOsc.Client('127.0.0.1', t.context.port); |
{ | ||
"name": "node-osc", | ||
"description": "pyOSC inspired library", | ||
"version": "6.0.0-rc.0", | ||
"version": "6.0.0-rc.1", | ||
"imports": { | ||
@@ -6,0 +6,0 @@ "#internal/*": { |
@@ -43,2 +43,19 @@ # node-osc | ||
### Sending OSC bundles: | ||
**WARNING**: Bundle support is Experimental and subject to change at any point. | ||
```js | ||
import { Bundle, Client } from 'node-osc'; | ||
// a bundle without an explicit time tag | ||
const bundle = new Bundle(['/one', 1], ['/two', 2], ['/three', 3]); | ||
// a bundle with a timetag of 10 | ||
bundle.append(new Bundle(10, ['/four', 4])); | ||
const client = new Client('127.0.0.1', 3333); | ||
client.send(bundle)); | ||
``` | ||
### Listening for OSC bundles: | ||
@@ -45,0 +62,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
70001
38
1392
108
4