Skip to content
Permalink
Browse files

custom-module: fix docs typo and allow omitting host and port in rece…

…ive shorthand
  • Loading branch information...
jean-emmanuel committed Mar 21, 2019
1 parent d6647f4 commit 27db8418f9b524f7d2a90090ee5e4ba2a3e6394d
Showing with 9 additions and 1 deletion.
  1. +2 −1 resources/docs/extras/custom-module.md
  2. +7 −0 src/server/osc/index.js
@@ -51,6 +51,7 @@ The module is executed in a restricted context, only a few globals are available
- `receiveOsc`: `function({host, port, address, args})`
- `send`: `function(host, port, address, arg1, arg2, ...)`
- `receive`: `function(host, port, address, arg1, arg2, ...)`
- `receive`: `function(address, arg1, arg2, ...)`
- `setTimeout`: `function(function, delay)`
- `clearTimeout`: `function(timeout)`
- `setInterval`: `function(function, delay)`
@@ -67,7 +68,7 @@ The module is executed in a restricted context, only a few globals are available
- `host`: `string` ip address, valid hostname or `midi`
- `port`: `integer` port number or `string` midi device name

`send` and `receive` are shorthands for `sendOsc` and `receiveOsc` that don't require args to be formatted as object (numbers are casted to floats by default):
`send` and `receive` are shorthands for `sendOsc` and `receiveOsc` that don't require args to be formatted as objects (numbers are casted to floats by default):

```js
// calling
@@ -48,6 +48,13 @@ class OscServer {
this.sendOsc({host, port, address, args:args.map(x=>this.parseArg(x))})
},
receive: (host, port, address, ...args)=>{
if (host[0] === '/') {
// host and port can be skipped
args.unshift(address)
args.unshift(port)
address = host
host = port = undefined
}
this.receiveOsc({host, port, address, args:args.map(x=>this.parseArg(x))})
},
app: this.customModuleEventEmitter,

0 comments on commit 27db841

Please sign in to comment.
You can’t perform that action at this time.