diff --git a/app/browser/js/app/callbacks.js b/app/browser/js/app/callbacks.js index e75a0941..64028a6e 100644 --- a/app/browser/js/app/callbacks.js +++ b/app/browser/js/app/callbacks.js @@ -11,7 +11,8 @@ module.exports = { // fetch ids corresponding to the osc path var path = data.path, pathref = path, - args = data.args + args = data.args, + target = data.target if (typeof data.args == 'object') { for (var i=data.args.length-1;i>=0;i--) { @@ -31,7 +32,13 @@ module.exports = { else if (args.length==1) args = args[0] for (i in WIDGETS_BY_PATH[pathref]) { - if (WIDGETS_BY_PATH[pathref][i]) WIDGETS_BY_PATH[pathref][i].setValue(args,false,true) + // 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 || !(WIDGETS_BY_PATH[pathref][i].target < target || WIDGETS_BY_PATH[pathref][i].target > target)) { + // update matching widgets + if (WIDGETS_BY_PATH[pathref][i]) WIDGETS_BY_PATH[pathref][i].setValue(args,false,true) + } } diff --git a/app/browser/js/app/parser.js b/app/browser/js/app/parser.js index 9331a1ed..60dfe002 100644 --- a/app/browser/js/app/parser.js +++ b/app/browser/js/app/parser.js @@ -155,6 +155,8 @@ module.exports.widgets = function(data,parent) { // create widget var widgetInner = createWidget[widgetData.type](widgetData,widgetContainer) + // store widgets target + widgetInner.target = widgetData.target widgetContainer[0].appendChild(widgetInner[0])