ValueTreeSynchroniser differentiate between type of stateChange

I’m using ValueTree objects in conjunction with ValueTreeSynchroniser to keep multiple ValueTree’s in sync over local network. In this case I’m talking about a server process and a couple of client processes.
When the local (client-side) ValueTree changes (by changing a UI element for instance) the ValueTreeSynchroniser sends that update to the server (via ValueTreeSynchroniser::stateChanged()). The server forwards the update to the other connected clients. When the client receives an update it applies it to the ValueTree which triggers the stateChanged() method again, which sends the update to the server which forwards the update to the other connected clients… You can see where this is going, we end up in a loop.

I’m looking for a way to find out (within ValueTreeSynchroniser) wether the ValueTree changed by an applyUpdate() or another kind of update (local property changed for instance). Is this possible?

Hey ruurdadema,

Have you ever found a solution for this problem?

Combined with this issue : Issues with ValueTreeSynchronizer - #3 by harryg

it seems that the ValueTreeSynchroniser isn’t really made for bidirectional communication, is it?

best regards

Hey,

No I haven’t because I moved away from using the ValueTreeSynchroniser for my case.

When using ValueTreeSynchroniser and ValueTree’s and where there are multiple components listening and manipulating the tree you have to be very careful to exclude the correct listener to not end up in a feedback loop using setPropertyExcludingListener().

And when updating widgets you also might have to pass juce::dontSendNotification to not let the widget trigger another update of the ValueTree (depends on your setup).

Another solution (depending on your case) might be to use 2 ValueTrees, one for each direction, but obviously that’t take more memory.

1 Like