How is the sync behaviour of the dashboard implemented?

Hi,

I was wondering how the synced behaviour of dashboard component implemented?

For example, there are two users viewing a slider on the dashboard. User A changed the slider value from 0 to 20, on the User B's page, the slider is updated from 0 to 20 as well.

Thank you for helping!

Hi @bigbean17

I am not an expert at DB - but plenty here who are.

But I believe it's based on a WebSocket.

Each browser (user) that has the DB open, has a connection to the DB WebSocket (running in the Node RED instance)

So any changes made by one user, is transmitted over the WebSocket to Node RED, and that event(s) is echoed out to all other users (browsers)

Sprinkle in some identifiable metadata in each event, the Javascript in the browser (that the WebSocket connection is made from) will change the state for all users.

You can see the WebSocket connection in your browser debug tools

You have a pane in the dashboard 2.0 for specifying, for each dashboard node, whether it should accept only input originated from its own page.

Note, that every message originating from a "server" node (e.g. inject, function), has no client context, hence broadcasted to all the dashboard node's related "widgets" (visual instances on the client pages).