I'm making a config node that creates a tcp connection. If there is no node using the config node we created, the config should not create a TCP connection. How do I solve this problem?
So how can I find out the number of nodes using this config node?
Have a look at how the
mqtt-broker config node handles this scenario.
It provides a pair of
deregister functions that the regular
mqtt in and
mqtt out nodes can call as part of the normal lifecycle to notify the config node of their existence.
The config node can then decide if and when to start and stop the underlying connection.