send osc message from the input port if specified
because some apps send their feedback messages to the sender directly
This commit is contained in:
parent
dc921a8e35
commit
ae99079408
3 changed files with 54 additions and 42 deletions
63
main/osc.js
63
main/osc.js
|
|
@ -2,13 +2,17 @@ var osc = require('node-osc')
|
|||
|
||||
module.exports = function(ipc, settings) {
|
||||
|
||||
if (settings.read('oscInPort')) {
|
||||
var oscServer = new osc.Server(settings.read('oscInPort'), '127.0.0.1')
|
||||
var inPort = settings.read('oscInPort'),
|
||||
debug = settings.read('debug')
|
||||
|
||||
if (inPort) {
|
||||
var oscServer = new osc.Server(inPort, '127.0.0.1')
|
||||
|
||||
oscServer.on('message', function (msg, rinfo) {
|
||||
var data = {path:msg.shift(),args:msg}
|
||||
if (data.args.length==1) data.args = data.args[0]
|
||||
ipc.send('receiveOsc',data)
|
||||
if (debug) console.log('OSC received: ',data,rinfo)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -17,35 +21,40 @@ module.exports = function(ipc, settings) {
|
|||
|
||||
var client = new osc.Client(host, port)
|
||||
|
||||
var message = new osc.Message(path)
|
||||
client._sock.bind({exclusive:false,reuseAddr:true,port:inPort},function(){
|
||||
|
||||
var numberType = precision==0?'integer':'float'
|
||||
|
||||
if (typeof args=='object' && args!==null) {
|
||||
for (i in args) {
|
||||
var arg = args[i]
|
||||
var message = new osc.Message(path)
|
||||
|
||||
if (typeof arg == 'number' && arg!==null && typeof arg != 'object') {
|
||||
message.append({type:numberType,value:arg})
|
||||
} else if (arg!==null && typeof arg != 'object'){
|
||||
message.append({type:'string',value:String(arg)})
|
||||
} else if (arg!==null && typeof arg == 'object' && arg.type && arg.value!=undefined) {
|
||||
message.append({type:arg.type,value:arg.value})
|
||||
}
|
||||
}
|
||||
} else if (args!==null){
|
||||
if (typeof args == 'number') {
|
||||
message.append({type:numberType,value:args})
|
||||
} else if (typeof args == 'object' && arg.type && arg.value!=undefined) {
|
||||
message.append({type:args.type,value:args.value})
|
||||
} else {
|
||||
message.append({type:'string',value:String(args)})
|
||||
}
|
||||
}
|
||||
var numberType = precision==0?'integer':'float'
|
||||
|
||||
if (typeof args=='object' && args!==null) {
|
||||
for (i in args) {
|
||||
var arg = args[i]
|
||||
|
||||
if (typeof arg == 'number' && arg!==null && typeof arg != 'object') {
|
||||
message.append({type:numberType,value:arg})
|
||||
} else if (arg!==null && typeof arg != 'object'){
|
||||
message.append({type:'string',value:String(arg)})
|
||||
} else if (arg!==null && typeof arg == 'object' && arg.type && arg.value!=undefined) {
|
||||
message.append({type:arg.type,value:arg.value})
|
||||
}
|
||||
}
|
||||
} else if (args!==null){
|
||||
if (typeof args == 'number') {
|
||||
message.append({type:numberType,value:args})
|
||||
} else if (typeof args == 'object' && arg.type && arg.value!=undefined) {
|
||||
message.append({type:args.type,value:args.value})
|
||||
} else {
|
||||
message.append({type:'string',value:String(args)})
|
||||
}
|
||||
}
|
||||
|
||||
client.send(message, function () {
|
||||
client.kill()
|
||||
})
|
||||
})
|
||||
|
||||
client.send(message, function () {
|
||||
client.kill()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue