isaacvitor / node-red-contrib-socketio-client

Socket.IO client to Node-Red

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to call emit on propose and not on connect

PhilippHaefele opened this issue · comments

I was thinking about on how to use emit node when i want to trigger an emit on an action (e.g. Button in dashboard is triggered). As normally the emit has to be in chain to the connect node it is triggerd on connect and then never again.

So added a function node to save the msg of the connect node to global/flow context with and then restored it when the action was triggered inside another function node before connecting the output to the emit node.

So the workaround works ok for me but shouldn't this be easier for other users.
Or did i miss something?

A solution would be the remove connect node and do handling of connection in configuration node so input of emit is for triggering emit and listener nod eonly will have an output. I'm not 100% sure if this is possible but i think i've seens this on other nodes already.
Also this will clean up the usage of nodes as you will only need one node per emit/listen.
Disadvantage of this solution is that it will totally break usage of all curretn users.

Another soultion would be that emit node does not trigger if it is set from connect node (e.g determined by topic) but caches the socket/socketId and user can use another node to the emit node to trigger it.
This will not break the current usage of the nodes but is not as clean as the first solution as is need many connections all comming from the connection node.

Do you had any thoughts about that already or any preferred soultion?