my goal is to improve a system of connection via internet between patches (websites that work as remote control interfaces) build with www.cables.gl and Touchdesigner.
Common to cables.gl and Touchdesigner environments are MQTT ops (cables) and DAT (td). Works well sending data back and forth via a MQTT Broker and using mqtt ops (cables) and socketcluster DAT (td).
Cables also supports socketcluster.io with socketcluster ops So with some help from the cables community I got a socketcluster.io server set up and running on heroku, cables.gl patches can hook up to. Data transmission performs very well.
But beyond my skills is (for now…):
How to get data served by a socketcluster server into Touchdesigner?
This would open up great opportunitie for sending/receiving values, arrays, strings, etc.
between whatever build with cables.gl and Touchdesigner (… and of course other setups, when coding clients from scratch)
Hope, someone can help me on that…
Unfortunately this will get complicated quickly. First step would be to find a python lib for socketcluster These libs usually have a blocking loop to read from the socket . Therefore you need to run them in a separate thread. But when they receive a message you are not allowed to modify TD from your custom thread. Hence you need to use queues to get back into TDs main thread.
Maybe there is a Socketcluster lib that works differently. One where you could check for new messages without a blocking loop, I.e. every frame via an execute DAT.
Alternatively you could try to find an asyncio based python lib for Socketcluster and use the workflow posted here Using asyncio module in TouchDesigner
Not sure if this will work , but worth a try
why not stick with mqtt and send all your datatypes as JSON?
Hello Achim, thanks for clearing that out. Not that experienced in writing code/scripting, but helps a lot!
… and yes, I found a good working alternative solution sticking with MQTT for messages from cables-patches to TD and using socketcluster for distributing data only between every instance of the cables patch running simultaneosly.
think next step should be in this case extending the cables ops with JSON input.
Right now, the only handle numbers/values or string as input, so they can output nested structures (like array of arrays or array of objects) only merged into one single string with one kind of separator.
If this don’t work out, I dive further into socketcluster “implementation” TD.
Thats the only python lib I found so far.
Yeah, that would be easiest for now. See if cables has a json module so you can send complex objects as a string , and then in the mqtt on message callback in TD just do a json.loads(payload.decode())