Let me leave my example here. Still does not seem to work with _socket
.
There is a "Client Collection" function node which logs which client has which socket id, and link it to the ?device=test1
or ?device=test2
in the URL parameter.
Based on this, the "Router" function node adds msg._socket
to the outgoing message before sending it through the uib-element. I checked the message leaving uib-element, and each has the correct _socket id. But still each message Chrome instance gets the message. I must be missing something simple.
[{"id":"ddf27e1052787ad5","type":"debug","z":"b4d7bc8a9540f906","name":"debug 72","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1040,"y":120,"wires":[]},{"id":"e181aa0641a3733f","type":"debug","z":"b4d7bc8a9540f906","name":"debug 73","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1040,"y":260,"wires":[]},{"id":"c545de0744ed3c75","type":"function","z":"b4d7bc8a9540f906","name":"Test 1","func":"let number = Math.floor(Math.random()*100);\nmsg.topic = \"test1\";\nmsg.payload = number;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":220,"wires":[["9e9cbe1ba459dfc1"]]},{"id":"bb23d9df851b734e","type":"inject","z":"b4d7bc8a9540f906","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"_uib","v":"{\"clientId\": \"eqQ9-YhGOxeAtcv2Etc5i\" }","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test","payload":"OK","payloadType":"str","x":470,"y":340,"wires":[["958d1f8c4fc837f6"]]},{"id":"01512afde4d3dcf2","type":"inject","z":"b4d7bc8a9540f906","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"_uib","v":"{\"clientId\": \"fdfdfdfdfdffsfsd\" }","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test","payload":"Not OK","payloadType":"str","x":490,"y":380,"wires":[["958d1f8c4fc837f6"]]},{"id":"958d1f8c4fc837f6","type":"uibuilder","z":"b4d7bc8a9540f906","name":"","topic":"","url":"uitest","okToGo":true,"fwdInMessages":false,"allowScripts":false,"allowStyles":false,"copyIndex":true,"templateFolder":"blank","extTemplate":"","showfolder":false,"reload":false,"sourceFolder":"src","deployedVersion":"6.8.2","showMsgUib":false,"title":"","descr":"","x":780,"y":220,"wires":[["ddf27e1052787ad5"],["e181aa0641a3733f","3bb6fe2cc8712d87"]]},{"id":"08a6f1d386d371a7","type":"inject","z":"b4d7bc8a9540f906","name":"Toggle Visible Msgs","props":[{"p":"_uib","v":"{\"command\":\"showMsg\"}","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":510,"y":420,"wires":[["958d1f8c4fc837f6"]]},{"id":"3bb6fe2cc8712d87","type":"function","z":"b4d7bc8a9540f906","name":"Client collection","func":"let clientlist = flow.get(\"clientlist\");\nif (clientlist === undefined) {\n clientlist = {};\n}\n\nif (msg.uibuilderCtrl === \"client connect\") {\n if (msg.urlParams.device !== undefined) {\n clientlist[msg.urlParams.device] = msg._socketId;\n }\n // return because the URL is missing the device parameter\n delete msg.uibuilderCtrl;\n return msg;\n}\nif (msg.uibuilderCtrl === \"client disconnect\") {\n delete clientlist[msg.urlParams.device];\n}\nflow.set(\"clientlist\", clientlist);","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1060,"y":320,"wires":[["e6824a35d4e387b0"]]},{"id":"f9de99c97f05389e","type":"inject","z":"b4d7bc8a9540f906","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":180,"wires":[["c545de0744ed3c75","b3f3614223dfa819"]]},{"id":"b3f3614223dfa819","type":"function","z":"b4d7bc8a9540f906","name":"Test 2","func":"let number = Math.floor(Math.random()*100+100);\nmsg.topic = \"test2\";\nmsg.payload = number;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":260,"wires":[["9e9cbe1ba459dfc1"]]},{"id":"9e9cbe1ba459dfc1","type":"function","z":"b4d7bc8a9540f906","name":"Router","func":"let clientlist = flow.get(\"clientlist\");\nif (clientlist === undefined) {\n return;\n}\n\nif (clientlist[msg.topic] !== undefined) {\n msg._socket = clientlist[msg.topic];\n return msg;\n}\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":240,"wires":[["30674faded2349bf"]]},{"id":"30674faded2349bf","type":"uib-element","z":"b4d7bc8a9540f906","name":"","topic":"","elementtype":"html","parent":"#more","parentSource":"","parentSourceType":"str","elementid":"more","elementId":"","elementIdSourceType":"str","heading":"","headingSourceType":"str","headingLevel":"h2","data":"payload","dataSourceType":"msg","position":"last","positionSourceType":"str","passthrough":false,"confData":{},"x":1050,"y":460,"wires":[["958d1f8c4fc837f6","f1923e4c384ac61a"]]},{"id":"e6824a35d4e387b0","type":"change","z":"b4d7bc8a9540f906","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"<p>Missing device parameter in the payload</p>","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":460,"wires":[["30674faded2349bf"]]},{"id":"f1923e4c384ac61a","type":"debug","z":"b4d7bc8a9540f906","name":"debug 81","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1230,"y":500,"wires":[]}]
test1 and test2 just random numbers, but test2 is always >100, test1 <100. Therefore I expect the window to show different numbers.