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()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,19 +5,20 @@ var baseDir = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'
|
|||
configFile = require('path').join(baseDir, '.open-stage-control')
|
||||
|
||||
var argv = require('yargs')
|
||||
.help('help').usage(`\nUsage:\n $0 [options]`).alias('h', 'help')
|
||||
.options({
|
||||
's':{alias:'sync',type:'array',describe:'synchronized hosts (ip:port pairs)'},
|
||||
'l':{alias:'load',type:'string',describe:'session file to load'},
|
||||
'p':{alias:'port',describe:'osc input port (for synchronization)'},
|
||||
'n':{alias:'nogui',describe:'disable default gui and makes the app availabe through http on specified port'},
|
||||
't':{alias:'theme',type:'array',describe:'theme name or path (mutliple values allowed)'}
|
||||
})
|
||||
.check(function(a,x){if(a.port==undefined || !isNaN(a.p)&&a.p>1023&&parseInt(a.p)===a.p){return true}else{throw 'Error: Port must be an integer >= 1024'}})
|
||||
.check(function(a,x){if(a.n==undefined || !isNaN(a.n)&&a.n>1023&&parseInt(a.n)===a.n){return true}else{throw 'Error: Port must be an integer >= 1024'}})
|
||||
.check(function(a,x){if(a.sync==undefined || a.s.join(' ').match('^([^:\s]*:[0-9]{4,5}[\s]*)*$')!=null){return true}else{throw 'Error: Sync hosts must be ip:port pairs & port must be >= 1024'}})
|
||||
.strict()
|
||||
.argv
|
||||
.help('help').usage(`\nUsage:\n $0 [options]`).alias('h', 'help')
|
||||
.options({
|
||||
's':{alias:'sync',type:'array',describe:'synchronized hosts (ip:port pairs)'},
|
||||
'l':{alias:'load',type:'string',describe:'session file to load'},
|
||||
'p':{alias:'port',describe:'osc input port (for synchronization)'},
|
||||
'd':{alias:'debug',describe:'log received osc messages in the console'},
|
||||
'n':{alias:'nogui',describe:'disable default gui and makes the app availabe through http on specified port'},
|
||||
't':{alias:'theme',type:'array',describe:'theme name or path (mutliple values allowed)'}
|
||||
})
|
||||
.check(function(a,x){if(a.p==undefined || !isNaN(a.p)&&a.p>1023&&parseInt(a.p)===a.p){return true}else{throw 'Error: Port must be an integer >= 1024'}})
|
||||
.check(function(a,x){if(a.n==undefined || !isNaN(a.n)&&a.n>1023&&parseInt(a.n)===a.n){return true}else{throw 'Error: Port must be an integer >= 1024'}})
|
||||
.check(function(a,x){if(a.s==undefined || a.s.join(' ').match('^([^:\s]*:[0-9]{4,5}[\s]*)*$')!=null){return true}else{throw 'Error: Sync hosts must be ip:port pairs & port must be >= 1024'}})
|
||||
.strict()
|
||||
.argv
|
||||
|
||||
module.exports = function(fs) {
|
||||
var config = function(){try {return JSON.parse(fs.readFileSync(configFile,'utf-8'))} catch(err) {return {}}}(),
|
||||
|
|
@ -28,7 +29,8 @@ module.exports = function(fs) {
|
|||
|
||||
appName: 'Open Stage Control',
|
||||
syncTargets: argv.s || false,
|
||||
oscInPort: argv.p || false,
|
||||
oscInPort: argv.p || 0,
|
||||
debug: argv.d || false,
|
||||
sessionFile: argv.l || false,
|
||||
noGui: argv.n || false,
|
||||
theme: function(){
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ Options:
|
|||
-h, --help display help
|
||||
-s, --sync synchronized hosts (ip:port pairs) (all osc messages will also be sent to these)
|
||||
-l, --load session file to load
|
||||
-p, --port osc input port (for synchronization)
|
||||
-p, --port osc input port (for synchronization / feedback)
|
||||
-d, --debug log received osc in the console
|
||||
-n, --nogui disable default gui and makes the app availabe through http on specified port
|
||||
-t, --theme theme name or path (mutliple values allowed)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue