osc: use new module's receive method
This commit is contained in:
parent
137658f3e9
commit
d6d25158a5
1 changed files with 1 additions and 40 deletions
|
|
@ -11,46 +11,7 @@ var callbacks = module.exports = {
|
|||
|
||||
receiveOsc: function(event,data){
|
||||
var data = data || event
|
||||
|
||||
if (data.address == '/EXEC') return remoteExec(data.args)
|
||||
|
||||
// fetch ids corresponding to the osc address
|
||||
var address = data.address,
|
||||
addressref = address,
|
||||
args = data.args,
|
||||
target = data.target
|
||||
|
||||
if (typeof data.args == 'object') {
|
||||
for (var i=data.args.length-1;i>=0;i--) {
|
||||
var ref = address+'||||'+data.args.slice(0,i).join('||||')
|
||||
if (widgetManager.getWidgetByAddress(ref).length) {
|
||||
addressref = ref
|
||||
args = data.args.slice(i,data.args.length)
|
||||
continue
|
||||
}
|
||||
}
|
||||
} else {
|
||||
args = data.args
|
||||
}
|
||||
|
||||
|
||||
if (args.length==0) args = null
|
||||
else if (args.length==1) args = args[0]
|
||||
|
||||
|
||||
let widget = widgetManager.getWidgetByAddress(addressref)
|
||||
|
||||
for (i in widget) {
|
||||
// if the message target is provided (when message comes from another client connected to the same server)
|
||||
// then we only update the widgets that have the same target
|
||||
// compare arrays using > and < operators (both false = equality)
|
||||
if (!target || !(widget[i].widgetData.target < target || widget[i].widgetData.target > target)) {
|
||||
// update matching widgets
|
||||
if (widget[i]) widget[i].setValue(args,{send:false,sync:true,fromExternal:!target})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
osc.receive(data)
|
||||
},
|
||||
|
||||
connected:function(){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue