custom-module: expose send and receive shorthands, expose client's address in app event handlers
This commit is contained in:
parent
9dadbf725f
commit
e7ec5208e1
4 changed files with 40 additions and 10 deletions
|
|
@ -44,11 +44,15 @@ class OscServer {
|
|||
console,
|
||||
sendOsc: this.sendOsc.bind(this),
|
||||
receiveOsc: this.receiveOsc.bind(this),
|
||||
send: (host, port, address, ...args)=>{
|
||||
this.sendOsc({host, port, address, args:args.map(x=>this.parseArg(x))})
|
||||
},
|
||||
receive: (host, port, address, ...args)=>{
|
||||
this.receiveOsc({host, port, address, args:args.map(x=>this.parseArg(x))})
|
||||
},
|
||||
app: this.customModuleEventEmitter,
|
||||
setTimeout,
|
||||
clearTimeout,
|
||||
setInterval,
|
||||
clearInterval,
|
||||
setTimeout, clearTimeout,
|
||||
setInterval, clearInterval,
|
||||
settings,
|
||||
options: customModule.slice(1, customModule.length)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,10 +51,12 @@ var bindCallbacks = function(callbacks) {
|
|||
|
||||
ipc.on('connection', function(client) {
|
||||
|
||||
var clientInfos = {address: client.address, id: client.id}
|
||||
|
||||
for (let name in callbacks) {
|
||||
client.on(name, (data)=>{
|
||||
if (osc.customModule) {
|
||||
osc.customModuleEventEmitter.emit(name, data, client.id)
|
||||
osc.customModuleEventEmitter.emit(name, data, clientInfos)
|
||||
}
|
||||
callbacks[name](data, client.id)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue