Processing and webpage

It is possible to get data from a webpage into your processing sketch. I know how to get pictures from the internet into the skecth or how to link to a website. But can you go the other way around? Is it possible to for example type a name in my processing sketch and send it to a website where I can see the name I typed in my sketch?

Hi,

One way of doing this is to use WebSockets, which is an extension of the HTTP protocol but full-duplex which means that both the server and the client can exchange in both directions without having to open and close a new connection.

This is great for real time interaction between two processes/machines over a network.

Seems like there’s already a Processing library to do that!!

And creating a WebSocket client application in JavaScript is very easy :

https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications

So when you type something on the Processing sketch, you send a JSON message through sockets with the event or the full text and in the client web page, you update the text dynamically through DOM manipulation :wink:

2 Likes