[2135] Expose Dashboard client connection/disconnection state to Node-RED flows - #2208
[2135] Expose Dashboard client connection/disconnection state to Node-RED flows#2208n-lark wants to merge 5 commits into
Conversation
…connect/gone) to ui-control, keyed on a durable clientId instead of the ephemeral socket.id
Steve-Mcl
left a comment
There was a problem hiding this comment.
Tested locally. Conditionally approved (I am on vacation after today)
Nit 1
Currently, it emits a payload string with client-connect / client-reconnect / client-gone
The first 2 are present tense and the last is past tense.
in my head, connect and reconnect means "now" however these messages occur after the event -so would client-connected / client-reconnected / client-gone not make more sense?
Nit 2
I could not get client-reconnect to fire unless i refreshed the dashboard (no amount of blocking the comms then recovery seemed to trigger it:
Happy to trust that was intended or a windows quirk
|
Hey @Steve-Mcl ty for the review and testing! Nit 1Updated to Nit 2Yahhh so for reconnected, it fires when the same browser leaves aka socket closes and returns within the 20s grace window. Blocking comms doesn't cleanly close the socket, so you won't see it that way. Ways to see it:
|
| } | ||
| ``` | ||
|
|
||
| The grace window means a brief blip or a page refresh does **not** fire `client-gone`; only a genuine departure does. Opening a second tab of a client that is already connected emits nothing (it is already present). |
There was a problem hiding this comment.
Wondering if this is ideal behaviour.
One of the reasons to expose socketId at all is to be able to direct a message to just that dashboard.
I may open the same dashboard in two tabs, and want to treat them as separate 'sessions'. Each of those sessions would be identifiable via clientId/socketId pair - but only if I know about them.
If we don't emit the client connected events for a second connection, we lose the ability to track all of the open dashboards.
Could we instead emit the events with an additional sockets property that is an array of all active sockets we see this clientId on?
There was a problem hiding this comment.
Yahhh so I think you can accomplish that here by combining the socket level events with the client-presence events. The socket connect/lost fire per tab and already come through with the clientId, so you can reconcile from that end and get the data you need.
The client-connected/reconnected/gone events are meant to be client-level presence with the grace window, not per-tab. So if you wanted to completely manage both you could use both channels, totally open to adding a sockets array to the presence events if it's useful, but firing one of these on every socket connect/disconnect feels like it'd just duplicate the socket events.
|
I pulled this branch and spent some time testing the presence paths locally: built the UI, ran it in Node-RED with a small flow capturing the Targeting a message by Presence tracking breaks permanently once the dashboard is removed and re-added. I deployed a flow without any dashboard nodes while a client was connected, then restored the dashboard. The client reconnected fine but no A The new The presence events carry a bare A few smaller ones:
The happy paths all worked well in my testing: stable id across reloads, |
Description
See #2135 (comment)
Changelog here: FlowFuse/website#5736
Related Issue(s)
Resolves #2135
Checklist
flowforge.yml?FlowFuse/helmto update ConfigMap TemplateFlowFuse/CloudProjectto update values for Staging/ProductionLabels
area:migrationlabel