Comparing version 8.0.12 to 8.1.0
@@ -8,4 +8,8 @@ 'use strict'; | ||
class Server extends node_events.EventEmitter { | ||
constructor(port, host, cb) { | ||
constructor(port, host='127.0.0.1', cb) { | ||
super(); | ||
if (typeof host === 'function') { | ||
cb = host; | ||
host = '127.0.0.1'; | ||
} | ||
if (!cb) cb = () => {}; | ||
@@ -19,3 +23,3 @@ let decoded; | ||
}); | ||
this._sock.bind(port); | ||
this._sock.bind(port, host); | ||
this._sock.on('listening', () => { | ||
@@ -22,0 +26,0 @@ this.emit('listening'); |
@@ -17,4 +17,4 @@ 'use strict'; | ||
tap.test('client: listen to message', (t) => { | ||
const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
tap.test('server: listen to message', (t) => { | ||
const oscServer = new nodeOsc.Server(t.context.port); | ||
const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
@@ -42,2 +42,51 @@ | ||
tap.test('server: no defined host', (t) => { | ||
const oscServer = new nodeOsc.Server(t.context.port); | ||
const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
t.plan(3); | ||
t.teardown(() => { | ||
oscServer.close(); | ||
client.close(); | ||
}); | ||
oscServer.on('message', (msg) => { | ||
t.same(msg, ['/test'], 'We should receive expected payload'); | ||
}); | ||
oscServer.on('/test', (msg) => { | ||
t.same(msg, ['/test'], 'We should receive expected payload'); | ||
}); | ||
client.send('/test', (err) => { | ||
t.error(err, 'there should be no error'); | ||
}); | ||
}); | ||
tap.test('server: callback as second arg', (t) => { | ||
t.plan(4); | ||
const oscServer = new nodeOsc.Server(t.context.port, () => { | ||
t.ok('callback called'); | ||
}); | ||
const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
t.teardown(() => { | ||
oscServer.close(); | ||
client.close(); | ||
}); | ||
oscServer.on('message', (msg) => { | ||
t.same(msg, ['/test'], 'We should receive expected payload'); | ||
}); | ||
oscServer.on('/test', (msg) => { | ||
t.same(msg, ['/test'], 'We should receive expected payload'); | ||
}); | ||
client.send('/test', (err) => { | ||
t.error(err, 'there should be no error'); | ||
}); | ||
}); | ||
tap.test('server: bad message', (t) => { | ||
@@ -44,0 +93,0 @@ t.plan(2); |
{ | ||
"name": "node-osc", | ||
"description": "pyOSC inspired library for sending and receiving OSC messages", | ||
"version": "8.0.12", | ||
"version": "8.1.0", | ||
"exports": { | ||
@@ -43,3 +43,3 @@ "require": "./dist/lib/index.js", | ||
"devDependencies": { | ||
"c8": "^8.0.0", | ||
"c8": "^8.0.1", | ||
"eslint": "^8.36.0", | ||
@@ -46,0 +46,0 @@ "get-port": "^6.1.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56659
1453