Note: For functionality like this, check out the Webserver DAT
Hey,
a while back I tried to make a simple websockets based chat app work with TouchDesigner and this little file was created.
All it does is use the TCP/IP DAT to act as a webserver on port 7001. The webpage it serves does not only contain the said chat but also 2 sliders which send their values back to TouchDesigner.
The whole thing is fairly simple:
If a client connects on port 7001 (just type localhost:7001 in your browser), the TcpIP callback analyzes the Header and sends back either the website to display or responds with a header that tells the Browser to switch into a Websocket connection.
If data is received which is not a header, the callback assumes that it must be a websocket message and starts decoding it.
There are some obvious problems here, especially the TcpIp DAT does not deal well with long messages send to it. Also the whole thing should be converted to deal with Bytes per Row instead of the currently used “One Row for all received Data”.
But this might be a good base for somebody trying to work on a browser based UI or so…
Cheers
Markus
TCPIPWebsocket.19.toe (17.6 KB)