gdcef icon indicating copy to clipboard operation
gdcef copied to clipboard

Communicating data between gdscript <-> browser

Open 3ddelano opened this issue 1 year ago • 8 comments
trafficstars

Is there a way I can send data from the browser side (javascript) to my gdscript and vice-versa? For example: If a html textbox is typed into can i get the data typed in gdscript?

3ddelano avatar Apr 20 '24 06:04 3ddelano

Hi @3ddelano the current way to interact with JS is given line

https://github.com/Lecrapouille/gdcef/blob/6f00652a97ad75af31e2d247bcb2ddf055ecbfc8/addons/gdcef/demos/2D/CEF.gd#L175

But you cannot get feedback from JS. This is a request https://github.com/Lecrapouille/gdcef/issues/40

Lecrapouille avatar Apr 20 '24 09:04 Lecrapouille

Oh thanks for the reply. Right now to get feedback from js im using a http server running in gdscript and the js makes API calls to the server. This works but needs a lot more code to setup.

3ddelano avatar Apr 20 '24 09:04 3ddelano

@3ddelano Using a HTTP server adds a lot of overhead as well. I'm working on a feature that will let you communicate easily between GDscript and the browser via a message protocol. You can use that to transfer JSON strings with instructions for each side as an example.

pimhakkert avatar Jul 21 '24 08:07 pimhakkert

Oh nice

3ddelano avatar Jul 21 '24 08:07 3ddelano

@3ddelano Using a HTTP server adds a lot of overhead as well. I'm working on a feature that will let you communicate easily between GDscript and the browser via a message protocol. You can use that to transfer JSON strings with instructions for each side as an example.

Do you have any update on this ?

berkaycimsir avatar Sep 04 '24 06:09 berkaycimsir

@berkaycimsir for the moment no concerning @pimhakkert

Lecrapouille avatar Sep 04 '24 07:09 Lecrapouille

@berkaycimsir for the moment no concerning @pimhakkert

Can you think of any shortcout way for this right now ?

I was able to send data from godot to my browser via MessageChannel but couldn't find a way to do it from browser to godot side.

berkaycimsir avatar Sep 04 '24 07:09 berkaycimsir

@berkaycimsir can you go to my gdcef discord https://discord.gg/EckEwy7S5U to show me a simple example of what you have made ? I need a basic example since I'm not a webdev.

Lecrapouille avatar Sep 04 '24 17:09 Lecrapouille