On Disconnect - GogoVega/node-red-contrib-firebase-realtime-database GitHub Wiki
The On Disconnect
node allows you to write or clear data when your client disconnects from the Database server. These updates occur whether your client disconnects cleanly or not, so you can rely on them to clean up data even if a connection is dropped or a client crashes.
[!CAUTION]
onDisconnect
operations are only triggered once!
This means that if your client re-disconnects again the event will not be triggered. Use the Send Message on Connected option to trigger your flow and re-inject your data to this node.
Below is the list and description of fields to configure for this node:
Database
Select or add a config-node. The config-node is your database on which this node will add/modify data for the defined path. Learn more about its role.
Method
Below is the list and description of query methods:
Cancel
Cancels all previously queued On Disconnect
set or update events for this location and all children.
If a write has been queued for this location via a Set
or Update
at a parent location, the write at this location will be canceled, though writes to sibling locations will still occur.
Remove
Ensures the data at this location is deleted when the client is disconnected. Any data at child locations will also be deleted.
Set
Ensures the data at this location is set to the specified value when the client is disconnected.
Set with Priority
Ensures the data at this location is set to the specified value and priority when the client is disconnected.
Update
As opposed to the Set
method, Update
can be use to selectively update only the referenced properties at the current location (instead of replacing all the child properties at the current location) when the client is disconnected.
[!WARNING]
payload
must be an object!
Path
The path to add/modify data. You can choose the string
option to set the path statically or the msg
option to set the path dynamically. By default, msg.topic
.
Send Message on Connected?
Sends a payload containing the current timestamp when the client is connected to your database.
Send Message on Disconnect?
Sends a payload containing the current timestamp when the client disconnects from your database.
Message Properties
Below are the properties of the incoming and outgoing message:
Input
payload
: the data that will be sent to the database.method
: the query type to apply to the data.priority
: the priority to apply to the data. By default 1.topic
: the path of the data to add/modify. By default 'topic'.
Output
payload
: Current Timestampevent
:Connect
orDisconnect
topic
: The database URL
Read more about message properties.